Skip to content

Commit

Permalink
Nudge kernel with kernel info requests until IOPub responds
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Dec 11, 2020
1 parent 4342e49 commit 4fe3430
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions notebook/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,26 @@ def finish():
shell_channel.stop_on_recv()

def on_shell_reply(msg):
self.log.debug("Nudge: shell info reply received: %s", self.kernel_id)
if not info_future.done():
self.log.debug("Nudge: shell info reply received: %s", self.kernel_id)
shell_channel.stop_on_recv()
self.log.debug("Nudge: resolving shell future")
info_future.set_result(msg)
if iopub_future.done():
finish()
self.log.debug("Setting results")
future.set_result(info_future.result())
if iopub_future.done():
finish()
self.log.debug("Nudge: resolving main future in shell handler")
future.set_result(info_future.result())

def on_iopub(msg):
self.log.debug("Nudge: First IOPub received: %s", self.kernel_id)
if not iopub_future.done():
self.log.debug("Nudge: first IOPub received: %s", self.kernel_id)
iopub_channel.stop_on_recv()
self.log.debug("Nudge: resolving iopub future")
iopub_future.set_result(None)
if info_future.done():
finish()
self.log.debug("Setting results")
future.set_result(info_future.result())
if info_future.done():
finish()
self.log.debug("Nudge: resolving main future in iopub handler")
future.set_result(info_future.result())

def on_timeout():
self.log.warning("Nudge: Timeout waiting for kernel_info_reply: %s", self.kernel_id)
Expand Down Expand Up @@ -346,8 +348,11 @@ def open(self, kernel_id):
km.add_restart_callback(self.kernel_id, self.on_kernel_restarted)
km.add_restart_callback(self.kernel_id, self.on_restart_failed, 'dead')

for channel, stream in self.channels.items():
stream.on_recv_stream(self._on_zmq_reply)
def subscribe(value):
for channel, stream in self.channels.items():
stream.on_recv_stream(self._on_zmq_reply)

connected.add_done_callback(subscribe)

return connected

Expand Down

0 comments on commit 4fe3430

Please sign in to comment.