From 1d9a77a4e3ba980014bf69174813a766838bfd3d Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 4 Sep 2023 18:35:57 +0200 Subject: [PATCH] Avoid showing "No answer for 5s" when shutdown is slow (#1320) --- jupyter_server/serverapp.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 6d38b2a149..a21a50c80a 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -833,6 +833,7 @@ class ServerApp(JupyterApp): ) _log_formatter_cls = LogFormatter # type:ignore[assignment] + _stopping = Bool(False, help="Signal that we've begun stopping.") @default("log_level") def _default_log_level(self): @@ -2264,6 +2265,10 @@ def _confirm_exit(self): self.stop(from_signal=True) return else: + if self._stopping: + # don't show 'no answer' if we're actually stopping, + # e.g. ctrl-C ctrl-C + return info(_i18n("No answer for 5s:")) info(_i18n("resuming operation...")) # no answer, or answer is no: @@ -2960,6 +2965,8 @@ async def _stop(self): def stop(self, from_signal=False): """Cleanup resources and stop the server.""" + # signal that stopping has begun + self._stopping = True if hasattr(self, "http_server"): # Stop a server if its set. self.http_server.stop()