Skip to content

Commit

Permalink
prefer SelectorEventLoop on Windows
Browse files Browse the repository at this point in the history
Selector is preferable when ~all out events are on zmq sockets, which uses the unsupported add_reader methods.
Tornado 6.1 puts these events in a background thread when Proactor is used, which we can avoid by using Selector.
  • Loading branch information
minrk committed May 13, 2021
1 parent 85e39ce commit 079f072
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,21 @@ def _init_asyncio_patch(self):
Pick the older SelectorEventLoopPolicy on Windows
if the known-incompatible default policy is in use.
Support for Proactor via a background thread is available in tornado 6.1,
but it is still preferable to run the Selector in the main thread
instead of the background.
do this as early as possible to make it a low priority and overrideable
ref: https://github.com/tornadoweb/tornado/issues/2608
FIXME: if/when tornado supports the defaults in asyncio,
remove and bump tornado requirement for py38
FIXME: if/when tornado supports the defaults in asyncio without threads,
remove and bump tornado requirement for py38.
Most likely, this will mean a new Python version
where asyncio.ProactorEventLoop supports add_reader and friends.
"""
if sys.platform.startswith("win") and sys.version_info >= (3, 8) and tornado.version_info < (6, 1):
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
import asyncio
try:
from asyncio import (
Expand Down

0 comments on commit 079f072

Please sign in to comment.