Skip to content

Commit

Permalink
Update for tornado 6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Dec 5, 2023
1 parent 290fcf6 commit edade0b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Distributed under the terms of the Modified BSD License.
from __future__ import annotations

import asyncio
import datetime
import errno
import gettext
Expand Down Expand Up @@ -2290,7 +2291,11 @@ def _confirm_exit(self) -> None:
# set it back to original SIGINT handler
# use IOLoop.add_callback because signal.signal must be called
# from main thread
self.io_loop.add_callback_from_signal(self._restore_sigint_handler)
try:
loop = asyncio.get_event_loop()
except RuntimeError:
pass
loop.add_signal_handler(self._restore_sigint_handler)

def _signal_stop(self, sig: t.Any, frame: t.Any) -> None:
"""Handle a stop signal."""
Expand Down Expand Up @@ -2984,7 +2989,11 @@ def stop(self, from_signal: bool = False) -> None:
# use IOLoop.add_callback because signal.signal must be called
# from main thread
if from_signal:
self.io_loop.add_callback_from_signal(self._stop)
try:
loop = asyncio.get_event_loop()
except RuntimeError:
pass
loop.add_signal_handler(self._stop)
else:
self.io_loop.add_callback(self._stop)

Expand Down

0 comments on commit edade0b

Please sign in to comment.