From 23ebf1b60859a2cb56bf206b266e4b6e8e1bfdec Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Sun, 10 Apr 2022 23:16:49 +0300 Subject: [PATCH] Show running threads on shutdown handler --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6292400..cfcb102 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ from loguru import logger - +import threading import time import FAPI @@ -43,6 +43,8 @@ def shutdown_callback(sig: int, frame) -> None: func = frame_info.function code_line = frame_info.code_context[0] logger.info(f'Currently at {func}:{frame_info.lineno}: {code_line!r}') + running_threads = ', '.join((thread.name for thread in threading.enumerate())) + logger.info(f'Running threads: {running_threads}') except Exception as e: logger.info(f"Can't detect where we are because {e}")