Skip to content
Advertisement

Tag: debugging

How to attach debugger to a python subproccess?

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

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

Advertisement