From a552fc0361a98022f675cca63938b36a0530e493 Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Thu, 21 Apr 2022 13:07:41 +0300 Subject: [PATCH] Add dump running threads by SIGUSR1 --- main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.py b/main.py index 16401d5..1a65173 100644 --- a/main.py +++ b/main.py @@ -57,6 +57,11 @@ def shutdown_callback(sig: int, frame) -> None: exit(0) +def threads_dump(sig: int, frame) -> None: + running_threads = ', '.join((thread.name for thread in threading.enumerate())) + logger.info(f'Running threads: {running_threads}') + + def discover(back_count: int = 0): """Discover new squads :param back_count: int how many squads back we should check, it is helpful to recheck newly created squads @@ -153,6 +158,7 @@ def main(): global can_be_shutdown signal.signal(signal.SIGTERM, shutdown_callback) signal.signal(signal.SIGINT, shutdown_callback) + signal.signal(signal.SIGUSR1, threads_dump) def help_cli() -> str: return """Possible arguments: