summary refs log tree commit diff
path: root/synapse/util/daemonize.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2021-10-12 10:21:26 +0100
committerBrendan Abolivier <babolivier@matrix.org>2021-10-12 10:21:26 +0100
commit6ce0dc0620228ab24749abc1e7d7efaad6e3f88a (patch)
tree3bd832712dfe139b18075bc2f072948203e6e201 /synapse/util/daemonize.py
parentMerge branch 'release-v1.44' into matrix-org-hotfixes (diff)
parentdisallow-untyped-defs for synapse.push (#11023) (diff)
downloadsynapse-6ce0dc0620228ab24749abc1e7d7efaad6e3f88a.tar.xz
Merge branch 'release-v1.45' into matrix-org-hotfixes
Diffstat (limited to 'synapse/util/daemonize.py')
-rw-r--r--synapse/util/daemonize.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/util/daemonize.py b/synapse/util/daemonize.py

index f1a351cfd4..de04f34e4e 100644 --- a/synapse/util/daemonize.py +++ b/synapse/util/daemonize.py
@@ -19,6 +19,8 @@ import logging import os import signal import sys +from types import FrameType, TracebackType +from typing import NoReturn, Type def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") -> None: @@ -97,7 +99,9 @@ def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") - # (we don't normally expect reactor.run to raise any exceptions, but this will # also catch any other uncaught exceptions before we get that far.) - def excepthook(type_, value, traceback): + def excepthook( + type_: Type[BaseException], value: BaseException, traceback: TracebackType + ) -> None: logger.critical("Unhanded exception", exc_info=(type_, value, traceback)) sys.excepthook = excepthook @@ -119,7 +123,7 @@ def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") - sys.exit(1) # write a log line on SIGTERM. - def sigterm(signum, frame): + def sigterm(signum: signal.Signals, frame: FrameType) -> NoReturn: logger.warning("Caught signal %s. Stopping daemon." % signum) sys.exit(0)