This is a simple module which enables you to have automatic post-mortem debugging as simply as possible
Install it using pip install autodebug.
Then in your Python script, before the possible exception write
import autodebug
Then if any uncaught exception happens, you'll be immediately transferred to debugger. Exactly the moment before the exception occured. So you'll have access to all variables and everything.
You can specify which Python debugger you want to use.
To do that simply set the environmental variable AUTO_DEBUG.
Possible debuggers currently are:
pdbfor built-in Python debuggeripdbforipdbPython debuggerpudbfor full-screen console Python debugger.
If you do not set the variable, pdb will be used, as it is built-in.
- Please note that this module uses custom
sys.excepthook, so if you are using your own, this module will not work, or will overwrite yourexcepthook(This depends on order ofimportand setting your ownexcepthook) - In order to make it work with
uwsgiyou have to pass--honour-stdinto uwsgi configuration. This will make it possible to debuguwsgiapplications!. But keep in mind, that if you've got more than 1 worker, and multiple people are using your application, the terminal output will be ugly. - The debugger won't start if it is imported inside interactive console, so it may not work in some IDEs. Experiment yourself, however it is adviced to start your programs using command line.