From 0ace0e831412d752d2441f0731dc6541f1e477c1 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Fri, 9 Aug 2024 13:05:42 +0100 Subject: [PATCH] add comments to explain signal handling under jupyterhub --- jupyter_server/serverapp.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index bf375cbef..8f611d27d 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -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 @@ -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)