Merge pull request #2752 from minrk/schedule-stop-callback

schedule IOLoop.stop on the main thread
pull/2774/head
Thomas Kluyver 9 years ago committed by GitHub
commit 3543f79254

@ -1273,7 +1273,9 @@ class NotebookApp(JupyterApp):
line = sys.stdin.readline()
if line.lower().startswith(yes) and no not in line.lower():
self.log.critical(_("Shutdown confirmed"))
ioloop.IOLoop.current().stop()
# schedule stop on the main thread,
# since this might be called from a signal handler
self.io_loop.add_callback_from_signal(self.io_loop.stop)
return
else:
print(_("No answer for 5s:"), end=' ')
@ -1282,11 +1284,11 @@ class NotebookApp(JupyterApp):
# set it back to original SIGINT handler
# use IOLoop.add_callback because signal.signal must be called
# from main thread
ioloop.IOLoop.current().add_callback(self._restore_sigint_handler)
self.io_loop.add_callback_from_signal(self._restore_sigint_handler)
def _signal_stop(self, sig, frame):
self.log.critical(_("received signal %s, stopping"), sig)
ioloop.IOLoop.current().stop()
self.io_loop.add_callback_from_signal(self.io_loop.stop)
def _signal_info(self, sig, frame):
print(self.notebook_info())

Loading…
Cancel
Save