Skip to content

Commit

Permalink
flush iopub before sending restarting/dead status messages
Browse files Browse the repository at this point in the history
to ensure (approximately) that all messages from the stopped kernel are delivered before the dead/restarting message
  • Loading branch information
minrk committed Jul 13, 2018
1 parent 1b69205 commit 4dab73a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions notebook/services/kernels/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ def on_close(self):
self._close_future.set_result(None)

def _send_status_message(self, status):
iopub = self.channels.get('iopub', None)
if iopub and not iopub.closed():
# flush IOPub before sending a restarting/dead status message
# ensures proper ordering on the IOPub channel
# that all messages from the stopped kernel have been delivered
iopub.flush(timeout=0.1)
msg = self.session.msg("status",
{'execution_state': status}
)
Expand Down

0 comments on commit 4dab73a

Please sign in to comment.