Skip to content

Commit 5e72a64

Browse files
authored
Merge pull request #390 from minrk/flush-shell-stream
flush after sending replies
2 parents 9d7a743 + fca4303 commit 5e72a64

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ipykernel/kernelbase.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ def dispatch_control(self, msg):
205205
sys.stdout.flush()
206206
sys.stderr.flush()
207207
self._publish_status(u'idle')
208+
# flush to ensure reply is sent
209+
self.control_stream.flush(zmq.POLLOUT)
208210

209211
def should_handle(self, stream, msg, idents):
210212
"""Check whether a shell-channel message should be handled
@@ -241,6 +243,9 @@ def dispatch_shell(self, stream, msg):
241243
if self._aborting:
242244
self._send_abort_reply(stream, msg, idents)
243245
self._publish_status(u'idle')
246+
# flush to ensure reply is sent before
247+
# handling the next request
248+
stream.flush(zmq.POLLOUT)
244249
return
245250

246251
msg_type = msg['header']['msg_type']
@@ -276,6 +281,9 @@ def dispatch_shell(self, stream, msg):
276281
sys.stdout.flush()
277282
sys.stderr.flush()
278283
self._publish_status(u'idle')
284+
# flush to ensure reply is sent before
285+
# handling the next request
286+
stream.flush(zmq.POLLOUT)
279287

280288
def pre_handler_hook(self):
281289
"""Hook to execute before calling message handler"""

0 commit comments

Comments
 (0)