Report current executing place on shutdown_callback

This commit is contained in:
norohind 2021-11-29 19:12:24 +03:00
parent 6bc4d0c1e4
commit 9349aace76
Signed by: norohind
GPG Key ID: 01C3BECC26FB59E1

12
main.py
View File

@ -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