Skip to content

Commit 4036788

Browse files
minrkblink1073
andauthored
Fix compatibility with tornado 6.2 beta (#956)
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
1 parent ba85b1c commit 4036788

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

ipykernel/control.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
from threading import Thread
22

3-
import zmq
4-
5-
if zmq.pyzmq_version_info() >= (17, 0):
6-
from tornado.ioloop import IOLoop
7-
else:
8-
# deprecated since pyzmq 17
9-
from zmq.eventloop.ioloop import IOLoop
3+
from tornado.platform.asyncio import AsyncIOLoop
104

115

126
class ControlThread(Thread):
137
def __init__(self, **kwargs):
148
Thread.__init__(self, name="Control", **kwargs)
15-
self.io_loop = IOLoop(make_current=False)
9+
self.io_loop = AsyncIOLoop(make_current=False)
1610
self.pydev_do_not_trace = True
1711
self.is_pydev_daemon_thread = True
1812

1913
def run(self):
2014
self.name = "Control"
21-
self.io_loop.make_current()
2215
try:
2316
self.io_loop.start()
2417
finally:

ipykernel/iostream.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717
from weakref import WeakSet
1818

1919
import zmq
20-
21-
if zmq.pyzmq_version_info() >= (17, 0):
22-
from tornado.ioloop import IOLoop
23-
else:
24-
# deprecated since pyzmq 17
25-
from zmq.eventloop.ioloop import IOLoop
26-
2720
from jupyter_client.session import extract_header
21+
22+
# AsyncIOLoop always creates a new asyncio event loop,
23+
# rather than the default AsyncIOMainLoop
24+
from tornado.platform.asyncio import AsyncIOLoop
2825
from zmq.eventloop.zmqstream import ZMQStream
2926

3027
# -----------------------------------------------------------------------------
@@ -63,7 +60,7 @@ def __init__(self, socket, pipe=False):
6360
self.background_socket = BackgroundSocket(self)
6461
self._master_pid = os.getpid()
6562
self._pipe_flag = pipe
66-
self.io_loop = IOLoop(make_current=False)
63+
self.io_loop = AsyncIOLoop(make_current=False)
6764
if pipe:
6865
self._setup_pipe_in()
6966
self._local = threading.local()
@@ -78,7 +75,6 @@ def __init__(self, socket, pipe=False):
7875

7976
def _thread_main(self):
8077
"""The inner loop that's actually run in a thread"""
81-
self.io_loop.make_current()
8278
self.io_loop.start()
8379
self.io_loop.close(all_fds=True)
8480

0 commit comments

Comments
 (0)