Skip to content
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

Run WindowsSelectorEventLoop event loop explicit on windows and py3. #7940

Merged
merged 5 commits into from
Apr 9, 2020

Conversation

p0psicles
Copy link
Contributor

@p0psicles p0psicles commented Apr 9, 2020

  • Required from python3.8.
  • PR is based on the DEVELOP branch
  • Don't send big changes all at once. Split up big PRs into multiple smaller PRs that are easier to manage and review
  • Read the contribution guide

@p0psicles p0psicles added this to the 0.3.15 milestone Apr 9, 2020
@medariox medariox merged commit 4e54342 into develop Apr 9, 2020
@medariox medariox deleted the feature/fix-run-windows-py38 branch April 9, 2020 12:48
@sharkykh
Copy link
Contributor

sharkykh commented Apr 9, 2020

FYI this will throw an exception for Python 3.5 and 3.6 as WindowsSelectorEventLoopPolicy is only available on 3.7.0 and newer:
https://docs.python.org/3.7/whatsnew/changelog.html#id98

bpo-33792: Add asyncio.WindowsSelectorEventLoopPolicy and asyncio.WindowsProactorEventLoopPolicy.

More info from Tornado:

On Windows, Tornado requires the WindowsSelectorEventLoop. This is
the default in Python 3.7 and older, but Python 3.8 defaults to an
event loop that is not compatible with Tornado. Applications that use
Tornado on Windows with Python 3.8 must call
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
at the beginning of their main file/function.

I suggest

# We need to set the WindowsSelectorEventLoop event loop on python 3 (3.8 and higher) running on windows
if sys.platform == 'win32':
    try:
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    except AttributeError:  # Only available since Python 3.7.0
        pass

@medariox
Copy link
Contributor

medariox commented Apr 9, 2020

@sharkykh
Good catch! Mind opening a PR?

@p0psicles
Copy link
Contributor Author

From what is Read was that it was always available below 3.8. But from 3.8 needed to be set explicitly.

Good to know.
Tnx

@sharkykh
Copy link
Contributor

sharkykh commented Apr 9, 2020

@medariox Sure #7942
@p0psicles It was the default up until 3.8. Tornado says that since 3.8 the default policy on Windows is not compatible with Tornado.

@sharkykh sharkykh mentioned this pull request Apr 9, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants