mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
exit notebook cleanly on SIGINT, SIGTERM
makes it a bit more likely security files, etc. will be cleaned up.
This commit is contained in:
parent
0344f92a62
commit
3c19b40d2f
@ -449,11 +449,20 @@ class NotebookApp(BaseIPythonApplication):
|
||||
self.port = port
|
||||
break
|
||||
|
||||
def init_signal(self):
|
||||
signal.signal(signal.SIGINT, self._handle_signal)
|
||||
signal.signal(signal.SIGTERM, self._handle_signal)
|
||||
|
||||
def _handle_signal(self, sig, frame):
|
||||
self.log.critical("received signal %s, stopping", sig)
|
||||
ioloop.IOLoop.instance().stop()
|
||||
|
||||
@catch_config_error
|
||||
def initialize(self, argv=None):
|
||||
super(NotebookApp, self).initialize(argv)
|
||||
self.init_configurables()
|
||||
self.init_webapp()
|
||||
self.init_signal()
|
||||
|
||||
def cleanup_kernels(self):
|
||||
"""shutdown all kernels
|
||||
|
Loading…
Reference in New Issue
Block a user