Skip to content

Commit

Permalink
Attempt fixing shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Feb 6, 2021
1 parent bcc22e2 commit ff50c68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion ipykernel/control.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from threading import Thread
import zmq
if zmq.pyzmq_version_info() >= (17, 0):
Expand Down
14 changes: 11 additions & 3 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,17 @@ def shutdown_request(self, stream, ident, parent):
)

self._at_shutdown()
# call sys.exit after a short delay
loop = ioloop.IOLoop.current()
loop.add_timeout(time.time()+0.1, loop.stop)

# Flush to ensure reply is sent before stopping loop
self.control_stream.flush(zmq.POLLOUT)

self.log.debug('Stopping control ioloop')
control_io_loop = self.control_stream.io_loop
control_io_loop.add_callback(control_io_loop.stop)

self.log.debug('Stopping shell ioloop')
shell_io_loop = self.shell_stream.io_loop
shell_io_loop.add_callback(shell_io_loop.stop)

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

0 comments on commit ff50c68

Please sign in to comment.