Skip to content

Commit

Permalink
Avoid showing "No answer for 5s" when shutdown is slow (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Sep 4, 2023
1 parent 93fde1a commit 1d9a77a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 1d9a77a

Please sign in to comment.