Skip to content

Commit ff50c68

Browse files
committed
Attempt fixing shutdown
1 parent bcc22e2 commit ff50c68

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

ipykernel/control.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from threading import Thread
32
import zmq
43
if zmq.pyzmq_version_info() >= (17, 0):

ipykernel/kernelbase.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,17 @@ def shutdown_request(self, stream, ident, parent):
672672
)
673673

674674
self._at_shutdown()
675-
# call sys.exit after a short delay
676-
loop = ioloop.IOLoop.current()
677-
loop.add_timeout(time.time()+0.1, loop.stop)
675+
676+
# Flush to ensure reply is sent before stopping loop
677+
self.control_stream.flush(zmq.POLLOUT)
678+
679+
self.log.debug('Stopping control ioloop')
680+
control_io_loop = self.control_stream.io_loop
681+
control_io_loop.add_callback(control_io_loop.stop)
682+
683+
self.log.debug('Stopping shell ioloop')
684+
shell_io_loop = self.shell_stream.io_loop
685+
shell_io_loop.add_callback(shell_io_loop.stop)
678686

679687
def do_shutdown(self, restart):
680688
"""Override in subclasses to do things when the frontend shuts down the

0 commit comments

Comments
 (0)