File tree Expand file tree Collapse file tree 3 files changed +2
-36
lines changed Expand file tree Collapse file tree 3 files changed +2
-36
lines changed Original file line number Diff line number Diff line change 7
7
import os
8
8
import re
9
9
import threading
10
- from contextlib import contextmanager
11
10
from glob import has_magic
12
11
from typing import TYPE_CHECKING , Iterable
13
12
@@ -120,18 +119,6 @@ def wrapper(*args, **kwargs):
120
119
return wrapper
121
120
122
121
123
- @contextmanager
124
- def _selector_policy ():
125
- original_policy = asyncio .get_event_loop_policy ()
126
- try :
127
- if os .name == "nt" and hasattr (asyncio , "WindowsSelectorEventLoopPolicy" ):
128
- asyncio .set_event_loop_policy (asyncio .WindowsSelectorEventLoopPolicy ())
129
-
130
- yield
131
- finally :
132
- asyncio .set_event_loop_policy (original_policy )
133
-
134
-
135
122
def get_loop ():
136
123
"""Create or return the default fsspec IO loop
137
124
@@ -142,8 +129,7 @@ def get_loop():
142
129
# repeat the check just in case the loop got filled between the
143
130
# previous two calls from another thread
144
131
if loop [0 ] is None :
145
- with _selector_policy ():
146
- loop [0 ] = asyncio .new_event_loop ()
132
+ loop [0 ] = asyncio .new_event_loop ()
147
133
th = threading .Thread (target = loop [0 ].run_forever , name = "fsspecIO" )
148
134
th .daemon = True
149
135
th .start ()
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def _wrap_all_sync_methods(self):
82
82
continue
83
83
84
84
method = getattr (self .sync_fs , method_name )
85
- if callable (method ) and not asyncio .iscoroutinefunction (method ):
85
+ if callable (method ) and not inspect .iscoroutinefunction (method ):
86
86
async_method = async_wrapper (method , obj = self )
87
87
setattr (self , f"_{ method_name } " , async_method )
88
88
Original file line number Diff line number Diff line change 1
1
import asyncio
2
2
import inspect
3
3
import io
4
- import os
5
4
import time
6
5
7
6
import pytest
@@ -131,25 +130,6 @@ async def main(**kwargs):
131
130
assert sum (asyncio .run (main ())) == 32 # override
132
131
133
132
134
- @pytest .mark .skipif (os .name != "nt" , reason = "only for windows" )
135
- def test_windows_policy ():
136
- from asyncio .windows_events import SelectorEventLoop
137
-
138
- loop = fsspec .asyn .get_loop ()
139
- policy = asyncio .get_event_loop_policy ()
140
-
141
- # Ensure that the created loop always uses selector policy
142
- assert isinstance (loop , SelectorEventLoop )
143
-
144
- # Ensure that the global policy is not changed and it is
145
- # set to the default one. This is important since the
146
- # get_loop() method will temporarily override the policy
147
- # with the one which uses selectors on windows, so this
148
- # check ensures that we are restoring the old policy back
149
- # after our change.
150
- assert isinstance (policy , asyncio .DefaultEventLoopPolicy )
151
-
152
-
153
133
def test_running_async ():
154
134
assert not fsspec .asyn .running_async ()
155
135
You can’t perform that action at this time.
0 commit comments