-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4537 - Use selector asyncio loop on windows tests #1748
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
Conversation
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240) | ||
# We explicitly use a different loop implementation here to prevent that issue | ||
if not _IS_SYNC and sys.platform == "win32": | ||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't call asyncio.set_event_loop_policy since that has global side effects. Instead we need to explicitly create our on loop, possibly only when the default would be the ProactorEventLoop.
and sys.platform == "win32" | ||
and asyncio.get_event_loop_policy() == asyncio.WindowsProactorEventLoopPolicy | ||
): | ||
loop = asyncio.WindowsSelectorEventLoopPolicy().new_event_loop() # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we just always use WindowsSelectorEventLoopPolicy on windows for now. I'm worried the WindowsProactorEventLoopPolicy check won't work for custom policies that use the proactor loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also call asyncio.SelectorEventLoop() directly.
# The default asyncio loop implementation on Windows | ||
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240) | ||
# We explicitly use a different loop implementation here to prevent that issue | ||
if not _IS_SYNC and sys.platform == "win32": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove not _IS_SYNC
here.
No description provided.