From 9349aace764a29480973d122df3fb283740408fc Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:12:24 +0300 Subject: [PATCH] Report current executing place on shutdown_callback --- main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1c27113..f61d5c6 100644 --- a/main.py +++ b/main.py @@ -65,8 +65,18 @@ Two modes: """ -def shutdown_callback(sig, frame) -> None: +def shutdown_callback(sig: int, frame) -> None: logger.info(f'Planning shutdown by {sig} signal') + try: + import inspect + frame_info = inspect.getframeinfo(frame) + func = frame_info.function + code_line = frame_info.code_context[0] + logger.info(f'Currently at {func}:{frame_info.lineno}: {code_line!r}') + + except Exception as e: + logger.info(f"Can't detect where we are because {e}") + global shutting_down shutting_down = True