I want to have a dict mapping from active frame (FrameType) objects to some data. Active meaning that it is in the current execution stack trace. However, holding a reference to the frame object is not a good idea because that would also keep inactive frames and that will blow up the memory very soon because of all the references
Tag: stack-trace
py.test Tracebacks: Highlight my code, fold frames of framework
Tracebacks of my tests are too long since I use pytest. Pytests includes surrounding code lines and a lot of other information. I like to see this information if the traceback line (frame) is from my code. But I don’t want to see it, if it is from a library or framework. I could not find a way to filter
Print current call stack from a method in code
In Python, how can I print the current call stack from within a method (for debugging purposes). Answer Here’s an example of getting the stack via the traceback module, and printing it: If you really only want to print the stack to stderr, you can use: Or to print to stdout (useful if want to keep redirected output together), use:
Showing the stack trace from a running Python application
I have this Python application that gets stuck from time to time and I can’t find out where. Is there any way to signal Python interpreter to show you the exact code that’s running? Some kind of on-the-fly stacktrace? Related questions: Print current call stack from a method in Python code Check what a running process is doing: print stack