-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async: always use selector loop policy #658
Conversation
I'll have to defer to you on this one, I don't know much about this loop choice. (failure appears to be because of conda server - rerunning) |
Have to admit that doing this for all
They can definitely create their own loop in whatever policy they choose, and pass it as |
I'll merge this, see if there's any knock-on effects later. |
For the record: we've received a feedback from a user on windows that this breaks fsspec/sshfs#29
Using that sshfs issue to monitor this, looks like we'll need to reconsider this change. |
Thanks @efiop . I don't know much about it, but happy to consider any change you think is needed. Of course, better if it can be fixed on your end :) |
Is there a recommended way to use the default event loop policy from the standard lib? This is what I have currently, which works, but feels a little verbose. I also wonder if the issues originally reported by @isidentical have been resolved in more recent python versions... try:
import s3fs
_loop = None
if _loop is None:
with fsspec.asyn.get_lock():
if _loop is None:
_loop = asyncio.new_event_loop()
th = threading.Thread(target=_loop.run_forever, name="fsspecIO")
th.daemon = True
th.start()
class DefaultEventLoopS3FS(s3fs.S3FileSystem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs, loop=_loop)
for protocol in fsspec.available_protocols():
try:
cls = fsspec.get_filesystem_class(protocol)
except ImportError:
continue
if cls == s3fs.S3FileSystem:
fsspec.register_implementation(protocol, DefaultEventLoopS3FS, clobber=True)
except ImportError:
s3fs = None |
Some little coding could allow fsspec.asyn._selector_policy to be configurable, then you don't have to do any subclassing and re-registering. As it is, you can easily set that module's attribute to a (context manager) function of your choice. |
Setting fsspec.asyn._selector_policy directly works for me! Is there any reason not to do this instead of my verbose code aside from that member being protected? |
Patching _selector_policy is fine, it will only apply to the current python process. |
Resolves #656