1

I want to run a small bit of python code when the notebook server gets a shutdown signal, is there a hook for this in the configuration?

Hamzeh Alsalhi
  • 403
  • 1
  • 4
  • 10
  • Current versions of IPython have [shutdown_hook](http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.hooks.html#IPython.core.hooks.shutdown_hook), this might help. – krassowski Jun 01 '18 at 16:50
  • See also https://stackoverflow.com/questions/39499748/override-ipython-exit-function-or-add-hooks-in-to-it – krassowski Jun 01 '18 at 16:51

1 Answers1

2

I don't think there is anything IPython specific. You can use the atexit module (https://docs.python.org/2/library/atexit.html) to run code before the Python interpreter quits.

vbraun
  • 1,851
  • 17
  • 14