You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
""""
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!""
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.
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
add above in \Lib\site-packages\tornado\platform\asyncio.py
Reacted by Astariul, Michael Bloem, Niklas, Sondre Lillebø Gundersen, Zhiwei Liang, dunzhichen, Michiel, Amir Z, Boburmirzo Khamrakulov, Ângelo Polotto and 25 more
Reacted by Astariul, Ângelo Polotto, Wok, Sebastian Cardona O, Sam Watts, Evgeny, RonS and Vinit1234
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())
Reacted by Nimish Bongale, Hannes, Almar Klein, kinglionsz and Hakim
Activity
stonebig commentedon May 11, 2019
so the ugly patch is to do this on Tornado asyncio.py
what should be the external procedure (per client packages, like for example Jupyter packages) ?
ploxiln commentedon May 11, 2019
I think you can do that at the beginning of your
main()(orif __name__ == '__main__':etc), it does not need to be patched into a tornado module. Just somewhere before any event loop is started.stonebig commentedon 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 commentedon 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.
docs: Add notice about WindowsSelectorEventLoop on py38
stonebig commentedon Jun 22, 2019
hum, let see how Jupyter team will handle the problem.
docs: Add notice about WindowsSelectorEventLoop on py38
docs: Add notice about WindowsSelectorEventLoop on py38
stonebig commentedon 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 commentedon 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
Select asyncio event loop on Windows for PY3.8+
4 remaining items
David-OConnor commentedon Apr 22, 2020
Still appears broken.
mivade commentedon Apr 22, 2020
For now you still need to use the workaround as described in the release notes.
David-OConnor commentedon Apr 23, 2020
Thanks; the workaround works.
fbosio commentedon Apr 24, 2020
That worked for me, it solved an issue I had with Spyder 4.1.2 and Python 3.8 in Miniconda, thank you very much!
answerquest commentedon Apr 26, 2020
for completeness, here's a workaround snippet that also ensures this happens only if python version is 3.8 or more:
qtconsole: Autospec creation for update from version 4.7.3 to version…
🏁 Fix startup under Python 3.8 and Windows
Added patch for async.io running on Windows with python3.8+ (known is…
Return to thread pool for subprocesses on Windows
Set the event loop policy on Windows and Python >=3.8.
Fixes add_reader NotImplementedError on Python 3.8 + Windows.
Crispy13 commentedon Nov 30, 2020
Still have the same issue
bdarnell commentedon Dec 1, 2020
This shouldn't be happening any more with Tornado 6.1; if you're still seeing problems please open a new issue with more details.
set_event_loop_policy for windows
PR (#1)