Created
November 17, 2014 06:06
-
-
Save simark/ef475431a804cad220f2 to your computer and use it in GitHub Desktop.
stacktraces of threads in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stacktraces(): | |
code = [] | |
for threadId, stack in sys._current_frames().items(): | |
code.append("\n# ThreadID: %s" % 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())) | |
return "\n".join(code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment