Skip to content

Commit

Permalink
Merge pull request #390 from minrk/flush-shell-stream
Browse files Browse the repository at this point in the history
flush after sending replies
  • Loading branch information
blink1073 authored May 16, 2019
2 parents 9d7a743 + fca4303 commit 5e72a64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def dispatch_control(self, msg):
sys.stdout.flush()
sys.stderr.flush()
self._publish_status(u'idle')
# flush to ensure reply is sent
self.control_stream.flush(zmq.POLLOUT)

def should_handle(self, stream, msg, idents):
"""Check whether a shell-channel message should be handled
Expand Down Expand Up @@ -241,6 +243,9 @@ def dispatch_shell(self, stream, msg):
if self._aborting:
self._send_abort_reply(stream, msg, idents)
self._publish_status(u'idle')
# flush to ensure reply is sent before
# handling the next request
stream.flush(zmq.POLLOUT)
return

msg_type = msg['header']['msg_type']
Expand Down Expand Up @@ -276,6 +281,9 @@ def dispatch_shell(self, stream, msg):
sys.stdout.flush()
sys.stderr.flush()
self._publish_status(u'idle')
# flush to ensure reply is sent before
# handling the next request
stream.flush(zmq.POLLOUT)

def pre_handler_hook(self):
"""Hook to execute before calling message handler"""
Expand Down

0 comments on commit 5e72a64

Please sign in to comment.