Skip to content

Commit a19816f

Browse files
committed
ensure control messages are handled without optional control_thread
and start handling them in `.start()` instead of `__init__`
1 parent 0702e32 commit a19816f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ipykernel/kernelbase.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ def __init__(self, **kwargs):
205205
self.control_handlers[msg_type] = getattr(self, msg_type)
206206

207207
self.control_queue = Queue()
208-
if 'control_thread' in kwargs:
209-
kwargs['control_thread'].io_loop.add_callback(self.poll_control_queue)
210208

211209
@gen.coroutine
212210
def dispatch_control(self, msg):
@@ -452,6 +450,13 @@ def start(self):
452450

453451
self.control_stream.on_recv(self.dispatch_control, copy=False)
454452

453+
if self.control_thread:
454+
control_loop = self.control_thread.io_loop
455+
else:
456+
control_loop = self.io_loop
457+
458+
control_loop.add_callback(self.poll_control_queue)
459+
455460
self.shell_stream.on_recv(
456461
partial(
457462
self.schedule_dispatch,

0 commit comments

Comments
 (0)