From dcef3a980cb9db03e21f3439f85a24269f029816 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 13 May 2021 06:00:38 -0500 Subject: [PATCH] Backport PR #669: Keep preferring SelectorEventLoop on Windows --- ipykernel/kernelapp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ipykernel/kernelapp.py b/ipykernel/kernelapp.py index ee691508e..fb3caa001 100644 --- a/ipykernel/kernelapp.py +++ b/ipykernel/kernelapp.py @@ -516,14 +516,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 (