diff --git a/examples/embedding/inprocess_qtconsole.py b/examples/embedding/inprocess_qtconsole.py index 18ce2863..7a976a31 100644 --- a/examples/embedding/inprocess_qtconsole.py +++ b/examples/embedding/inprocess_qtconsole.py @@ -1,54 +1,24 @@ """An in-process qt console app.""" import os -import sys import tornado from IPython.lib import guisupport from qtconsole.inprocess import QtInProcessKernelManager from qtconsole.rich_ipython_widget import RichIPythonWidget +assert tornado.version_info >= (6, 1) + def print_process_id(): """Print the process id.""" print("Process ID is:", os.getpid()) -def init_asyncio_patch(): - """set default asyncio policy to be compatible with tornado - Tornado 6 (at least) is not compatible with the default - asyncio implementation on Windows - Pick the older SelectorEventLoopPolicy on Windows - if the known-incompatible default policy is in use. - do this as early as possible to make it a low priority and overridable - ref: https://github.com/tornadoweb/tornado/issues/2608 - FIXME: if/when tornado supports the defaults in asyncio, - remove and bump tornado requirement for py38 - """ - if ( - sys.platform.startswith("win") - and sys.version_info >= (3, 8) - and tornado.version_info < (6, 1) - ): - import asyncio - - try: - from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy - except ImportError: - pass - # not affected - else: - if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy: - # WindowsProactorEventLoopPolicy is not compatible with tornado 6 - # fallback to the pre-3.8 default of Selector - asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()) - - def main(): """The main entry point.""" # Print the ID of the main process print_process_id() - init_asyncio_patch() app = guisupport.get_app_qt4() # Create an in-process kernel diff --git a/ipykernel/kernelapp.py b/ipykernel/kernelapp.py index 394f52a4..55efaa8e 100644 --- a/ipykernel/kernelapp.py +++ b/ipykernel/kernelapp.py @@ -657,7 +657,7 @@ def _init_asyncio_patch(self): where asyncio.ProactorEventLoop supports add_reader and friends. """ - if sys.platform.startswith("win") and sys.version_info >= (3, 8): + if sys.platform.startswith("win"): import asyncio try: diff --git a/tests/test_eventloop.py b/tests/test_eventloop.py index 77596eed..62a7f8ba 100644 --- a/tests/test_eventloop.py +++ b/tests/test_eventloop.py @@ -7,7 +7,6 @@ import time import pytest -import tornado from ipykernel.eventloops import ( enable_gui, @@ -16,7 +15,7 @@ loop_tk, ) -from .utils import execute, flush_channels, start_new_kernel +from .utils import flush_channels, start_new_kernel KC = KM = None @@ -61,25 +60,6 @@ def _setup_env(): """ -@pytest.mark.skipif(tornado.version_info < (5,), reason="only relevant on tornado 5") -def test_asyncio_interrupt(): - assert KM is not None - assert KC is not None - flush_channels(KC) - msg_id, content = execute("%gui asyncio", KC) - assert content["status"] == "ok", content - - flush_channels(KC) - msg_id, content = execute(async_code, KC) - assert content["status"] == "ok", content - - KM.interrupt_kernel() - - flush_channels(KC) - msg_id, content = execute(async_code, KC) - assert content["status"] == "ok" - - windows_skip = pytest.mark.skipif(os.name == "nt", reason="causing failures on windows") diff --git a/tests/test_kernel.py b/tests/test_kernel.py index 88f02ae9..89d5e390 100644 --- a/tests/test_kernel.py +++ b/tests/test_kernel.py @@ -212,7 +212,7 @@ def test_sys_path_profile_dir(): @flaky(max_runs=3) @pytest.mark.skipif( - sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)), + sys.platform == "win32" or (sys.platform == "darwin"), reason="subprocess prints fail on Windows and MacOS Python 3.8+", ) def test_subprocess_print(): @@ -267,7 +267,7 @@ def test_subprocess_noprint(): @flaky(max_runs=3) @pytest.mark.skipif( - sys.platform == "win32" or (sys.platform == "darwin" and sys.version_info >= (3, 8)), + (sys.platform == "win32") or (sys.platform == "darwin"), reason="subprocess prints fail on Windows and MacOS Python 3.8+", ) def test_subprocess_error():