From 70565fe397dbd2095951fe750e82b63b589e6b50 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 14 Jun 2022 13:45:15 +0200 Subject: [PATCH 1/3] make sure to always test with prerelease dependencies --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 151dd3e9f..1f168e533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Install the Python dependencies run: | - pip install .[test] codecov + pip install --pre .[test] codecov - name: Install matplotlib if: ${{ !startsWith(matrix.os, 'macos') && !startsWith(matrix.python-version, 'pypy') }} From 99918a3163089b6ca55fce5422051e86f0dd7dc4 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 14 Jun 2022 14:58:55 +0200 Subject: [PATCH 2/3] explicitly create new asyncio loops for background threads rather than rely on deprecated IOLoop(make_current=False) AsyncIOLoop is explicit about owning its own loop, without making it 'current' --- ipykernel/control.py | 11 ++--------- ipykernel/iostream.py | 14 +++++--------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ipykernel/control.py b/ipykernel/control.py index bb5f7b5f9..ee475188d 100644 --- a/ipykernel/control.py +++ b/ipykernel/control.py @@ -1,24 +1,17 @@ from threading import Thread -import zmq - -if zmq.pyzmq_version_info() >= (17, 0): - from tornado.ioloop import IOLoop -else: - # deprecated since pyzmq 17 - from zmq.eventloop.ioloop import IOLoop +from tornado.platform.asyncio import AsyncIOLoop class ControlThread(Thread): def __init__(self, **kwargs): Thread.__init__(self, name="Control", **kwargs) - self.io_loop = IOLoop(make_current=False) + self.io_loop = AsyncIOLoop(make_current=False) self.pydev_do_not_trace = True self.is_pydev_daemon_thread = True def run(self): self.name = "Control" - self.io_loop.make_current() try: self.io_loop.start() finally: diff --git a/ipykernel/iostream.py b/ipykernel/iostream.py index 419d092c3..43644c224 100644 --- a/ipykernel/iostream.py +++ b/ipykernel/iostream.py @@ -17,14 +17,11 @@ from weakref import WeakSet import zmq - -if zmq.pyzmq_version_info() >= (17, 0): - from tornado.ioloop import IOLoop -else: - # deprecated since pyzmq 17 - from zmq.eventloop.ioloop import IOLoop - from jupyter_client.session import extract_header + +# AsyncIOLoop always creates a new asyncio event loop, +# rather than the default AsyncIOMainLoop +from tornado.platform.asyncio import AsyncIOLoop from zmq.eventloop.zmqstream import ZMQStream # ----------------------------------------------------------------------------- @@ -63,7 +60,7 @@ def __init__(self, socket, pipe=False): self.background_socket = BackgroundSocket(self) self._master_pid = os.getpid() self._pipe_flag = pipe - self.io_loop = IOLoop(make_current=False) + self.io_loop = AsyncIOLoop(make_current=False) if pipe: self._setup_pipe_in() self._local = threading.local() @@ -78,7 +75,6 @@ def __init__(self, socket, pipe=False): def _thread_main(self): """The inner loop that's actually run in a thread""" - self.io_loop.make_current() self.io_loop.start() self.io_loop.close(all_fds=True) From 1fb7ce2abc5d8d0e91ad8aa12e22bc95e4068789 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 14 Jun 2022 15:40:39 -0500 Subject: [PATCH 3/3] Update .github/workflows/ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f168e533..151dd3e9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Install the Python dependencies run: | - pip install --pre .[test] codecov + pip install .[test] codecov - name: Install matplotlib if: ${{ !startsWith(matrix.os, 'macos') && !startsWith(matrix.python-version, 'pypy') }}