Skip to content

Commit 3543f79

Browse files
authored
Merge pull request #2752 from minrk/schedule-stop-callback
schedule IOLoop.stop on the main thread
2 parents 60f81e4 + b2bd0ff commit 3543f79

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

notebook/notebookapp.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,9 @@ def _confirm_exit(self):
12731273
line = sys.stdin.readline()
12741274
if line.lower().startswith(yes) and no not in line.lower():
12751275
self.log.critical(_("Shutdown confirmed"))
1276-
ioloop.IOLoop.current().stop()
1276+
# schedule stop on the main thread,
1277+
# since this might be called from a signal handler
1278+
self.io_loop.add_callback_from_signal(self.io_loop.stop)
12771279
return
12781280
else:
12791281
print(_("No answer for 5s:"), end=' ')
@@ -1282,11 +1284,11 @@ def _confirm_exit(self):
12821284
# set it back to original SIGINT handler
12831285
# use IOLoop.add_callback because signal.signal must be called
12841286
# from main thread
1285-
ioloop.IOLoop.current().add_callback(self._restore_sigint_handler)
1287+
self.io_loop.add_callback_from_signal(self._restore_sigint_handler)
12861288

12871289
def _signal_stop(self, sig, frame):
12881290
self.log.critical(_("received signal %s, stopping"), sig)
1289-
ioloop.IOLoop.current().stop()
1291+
self.io_loop.add_callback_from_signal(self.io_loop.stop)
12901292

12911293
def _signal_info(self, sig, frame):
12921294
print(self.notebook_info())

0 commit comments

Comments
 (0)