Skip to content

Commit

Permalink
Fix compatibility with tornado 6.2 beta (#956)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
  • Loading branch information
minrk and blink1073 authored Jun 14, 2022
1 parent ba85b1c commit 4036788
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
11 changes: 2 additions & 9 deletions ipykernel/control.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
14 changes: 5 additions & 9 deletions ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand Down

0 comments on commit 4036788

Please sign in to comment.