Gern Blanston
Gern Blanston

Reputation: 42660

How to debug python script that is crashing python

I'm trying to help debug a python script that is causing python (2.7) itself to crashes.

So my question:

GB

Upvotes: 15

Views: 29804

Answers (1)

Steven Kryskalla
Steven Kryskalla

Reputation: 14649

So there are no exceptions in the log? It just exits randomly at different spots?

To see every statement as it's executed, use the trace module:

python -u -m trace -t program.py

To run the program in the debugger, use pdb:

python -m pdb program.py

With those two you should be able to see if it's something within the program causing it to exit. If you don't see any evidence or pattern then it could be something outside of the program causing it to die.

On Linux I would also try running the program with strace and watching for the OOM killer or segfaults. Not sure what similar steps would be in Windows, Windows doesn't have an OOM killer.

Upvotes: 22

Related Questions