I need to debug a child process spawned by multiprocessing.Process(). The pdb degugger seems to be unaware of forking and unable to attach to already running processes. Are there any smarter python debuggers which can be attached to a subprocess? Answer Winpdb is pretty much the definition of a smarter Python debugger. It explicitly supports going down a fork, not
Tag: debugging
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:
Starting python debugger automatically on error
This is a question I have wondered about for quite some time, yet I have never found a suitable solution. If I run a script and I come across, let’s say an IndexError, python prints the line, location and quick description of the error and exits. Is it possible to automatically start pdb when an error is encountered? I am
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