mirror of
https://github.com/norohind/jubilant-system.git
synced 2025-04-21 00:17:35 +03:00
Report current executing place on shutdown_callback
This commit is contained in:
parent
6bc4d0c1e4
commit
9349aace76
12
main.py
12
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user