1
0
Fork 0

Catch SIGUSR1: log threads stack traces

This commit is contained in:
nemunaire 2015-05-15 00:05:12 +02:00
parent b0678ceb84
commit f160411f71
1 changed files with 9 additions and 0 deletions

View File

@ -152,6 +152,15 @@ def main():
context.sync_queue.put_nowait(["loadconf", path])
signal.signal(signal.SIGHUP, sighuphandler)
def sigusr1handler(signum, frame):
"""On SIGHUSR1, display stacktraces"""
import traceback
for threadId, stack in sys._current_frames().items():
logger.debug("########### Thread %d:\n%s",
threadId,
"".join(traceback.format_stack(stack)))
signal.signal(signal.SIGUSR1, sigusr1handler)
# Here we go!
context.start()