The Wayback Machine - https://web.archive.org/web/20201112042412/https://github.com/tornadoweb/tornado/issues/2608
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

Prepare for python 3.8 on windows #2608

Closed
bdarnell opened this issue Mar 2, 2019 · 12 comments
Closed

Prepare for python 3.8 on windows #2608

bdarnell opened this issue Mar 2, 2019 · 12 comments

Comments

@bdarnell
Copy link
Member

@bdarnell bdarnell commented Mar 2, 2019

Python 3.8 asyncio is going to make the "proactor" event loop the default, instead of the current "selector" event loop. This is a problem for Tornado because the proactor event loop doesn't support the unix-style add_reader APIs that Tornado uses.

Anyone using Tornado 5+ on windows with python 3.8 will need to configure asyncio to use the selector event loop; we'll have to document this. We should also try to detect the use of a proactor event loop and give a clear error message (the current NotImplementError message can be seen in this SO post).

I don't think it would be appropriate for Tornado itself to configure the selector event loop automatically, since it has drawbacks (less scalability than the proactor loop, the user may want to use another event loop entirely like uvloop). Applications using Tornado (like jupyter notebook) may wish to do so, though. Maybe there should even be some more magical way to choose the selector loop (an environment variable? a special package to install?) to avoid the need to build this in to each application, although i don't really like the idea of that much magic.

@stonebig
Copy link

@stonebig stonebig commented May 11, 2019

so the ugly patch is to do this on Tornado asyncio.py

import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())  # python-3.8.0a4

what should be the external procedure (per client packages, like for example Jupyter packages) ?

@ploxiln
Copy link
Contributor

@ploxiln ploxiln commented May 11, 2019

I think you can do that at the beginning of your main() (or if __name__ == '__main__': etc), it does not need to be patched into a tornado module. Just somewhere before any event loop is started.

@stonebig
Copy link

@stonebig stonebig commented May 28, 2019

https://twitter.com/VictorStinner/status/1133323227298697216?s=09

""""
asyncio on Windows will be a much better experience in Python 3.8: IOCP event loop by default (subprocess support), CTRL+C and UDP support. https://t.co/MNpctRWma4 (outdated doc, UDP support is merged). Well done Andrew Svetlov @andrew_svetlov and others who made this possible!""

@bdarnell
Copy link
Member Author

@bdarnell bdarnell commented Jun 22, 2019

I've filed https://bugs.python.org/issue37373 upstream but it doesn't look like we'll be able to have any solution besides documenting the need for applications to set the event loop policy.

@stonebig
Copy link

@stonebig stonebig commented Jun 22, 2019

hum, let see how Jupyter team will handle the problem.

@stonebig
Copy link

@stonebig stonebig commented Nov 3, 2019

also, as a remark, trio project (and uvloop ?) somehow succeeded to make the proactorLoop work in "select" mode.

python-trio/trio@2ce3bcc

@rajnitish
Copy link

@rajnitish rajnitish commented Nov 6, 2019

not implemented till date
import sys

if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

add above in \Lib\site-packages\tornado\platform\asyncio.py

@answerquest
Copy link

@answerquest answerquest commented Apr 26, 2020

for completeness, here's a workaround snippet that also ensures this happens only if python version is 3.8 or more:

import sys, asyncio

if sys.version_info[0]==3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
clrpackages pushed a commit to clearlinux-pkgs/qtconsole that referenced this issue May 15, 2020
… 4.7.4

Carlos Cordoba (3):
      Back to work
      Update Changelog
      Release 4.7.4

Eric Prestat (1):
      Workaround tornado+py38+windows compatibility issue, see tornadoweb/tornado#2608.

Ray Osborn (1):
      Fixes a TypeError in CallTipWidget

Stephannie Jimenez (1):
      verify if event has attribute button

dalthviz (6):
      Use Python 2.7.17 to prevent memory segfaults when running the tests
      Fix CompletionWidget common prefix handling
      Add test for the CompletionWidget handling of common paths
      Redo dot completion handling and add test
      Fix test_common_path_complete - Python 2
      Testing
foosel added a commit to OctoPrint/OctoPrint that referenced this issue Jun 26, 2020
Python 3.8 makes proactor event loop the default on Windows, Tornado
doesn't like that.

See also tornadoweb/tornado#2608
georgeprichici added a commit to georgeprichici/metadefender-menlo-integration that referenced this issue Aug 7, 2020
remram44 added a commit to remram44/taguette that referenced this issue Aug 26, 2020
This reverts 2c3112f.

Windows only supports subprocesses with the asyncio ProactorEventLoop,
however tornado only supports the SelectorEventLoop.

tornadoweb/tornado#2608
mcteo added a commit to mcteo/django-livereload-server that referenced this issue Oct 17, 2020
`asyncio`'s default event loop is changed in Python3.8, causing Tornado to break on Windows.

The fix is simply to ensure the old event loop is kept, when ran on Python >= 3.8, and on Windows.

More info can be found here:
* tornadoweb/tornado#2608
* lepture/python-livereload#209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants
You can’t perform that action at this time.