Skip to content

Commit

Permalink
add comments to explain signal handling under jupyterhub
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Aug 9, 2024
1 parent 74655ce commit 0ace0e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,14 @@ def init_signal(self) -> None:
signal.signal(signal.SIGINFO, self._signal_info)

def _handle_sigint(self, sig: t.Any, frame: t.Any) -> None:
"""SIGINT handler spawns confirmation dialog"""
"""SIGINT handler spawns confirmation dialog
Note:
JupyterHub replaces this method with _signal_stop
in order to bypass the interactive prompt.
https://github.com/jupyterhub/jupyterhub/pull/4864
"""
# register more forceful signal handler for ^C^C case
signal.signal(signal.SIGINT, self._signal_stop)
# request confirmation dialog in bg thread, to avoid
Expand Down Expand Up @@ -2446,7 +2453,13 @@ def _confirm_exit(self) -> None:
self.io_loop.add_callback_from_signal(self._restore_sigint_handler)

def _signal_stop(self, sig: t.Any, frame: t.Any) -> None:
"""Handle a stop signal."""
"""Handle a stop signal.
Note:
JupyterHub configures this method to be called for SIGINT.
https://github.com/jupyterhub/jupyterhub/pull/4864
"""
self.log.critical(_i18n("received signal %s, stopping"), sig)
self.stop(from_signal=True)

Expand Down

0 comments on commit 0ace0e8

Please sign in to comment.