http://stackoverflow.com/a/2569696 to answer http://stackoverflow.com/questions/132058/showing-the-stack-trace-from-a-running-python-application based on http://bzimmer.ziclix.com/2008/12/17/python-thread-dumps/ (403) import threading import traceback import sys # see also traceback.print_stack() def _dumpstacks(): id2name = dict([(th.ident, th.name) for th in threading.enumerate()]) code = [] for threadId, stack in sys._current_frames().items(): code.append("\n# Thread: %s(%d)" % (id2name.get(threadId,""), threadId)) for filename, lineno, name, line in traceback.extract_stack(stack): code.append('File: "%s", line %d, in %s' % (filename, lineno, name)) if line: code.append(" %s" % (line.strip())) print "\n".join(code) def dumpstacks(signal, frame): _dumpstacks() import signal signal.signal(signal.SIGQUIT, dumpstacks) print "Hello, world" _dumpstacks()