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 77import os
88import re
99import threading
10- from contextlib import contextmanager
1110from glob import has_magic
1211from typing import TYPE_CHECKING , Iterable
1312
@@ -120,18 +119,6 @@ def wrapper(*args, **kwargs):
120119 return wrapper
121120
122121
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-
135122def get_loop ():
136123 """Create or return the default fsspec IO loop
137124
@@ -142,8 +129,7 @@ def get_loop():
142129 # repeat the check just in case the loop got filled between the
143130 # previous two calls from another thread
144131 if loop [0 ] is None :
145- with _selector_policy ():
146- loop [0 ] = asyncio .new_event_loop ()
132+ loop [0 ] = asyncio .new_event_loop ()
147133 th = threading .Thread (target = loop [0 ].run_forever , name = "fsspecIO" )
148134 th .daemon = True
149135 th .start ()
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def _wrap_all_sync_methods(self):
8282 continue
8383
8484 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 ):
8686 async_method = async_wrapper (method , obj = self )
8787 setattr (self , f"_{ method_name } " , async_method )
8888
Original file line number Diff line number Diff line change 11import asyncio
22import inspect
33import io
4- import os
54import time
65
76import pytest
@@ -131,25 +130,6 @@ async def main(**kwargs):
131130 assert sum (asyncio .run (main ())) == 32 # override
132131
133132
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-
153133def test_running_async ():
154134 assert not fsspec .asyn .running_async ()
155135
You can’t perform that action at this time.
0 commit comments