How to debug python script that causes python to crash

I am trying to help debug a python script that will cause python (2.7) itself to fail.

  • The script writes some information to a file and ends at another stop each time it starts, or at least what it writes out is in a different place.
  • The script already has a try \ catch.
  • script worked previously without errors
  • This is on Window 2008 servers with enough RAM and with little CPU usage.

So my question is:

  • Are there any tools or methods that could help?
    • I see that there is a pdb module that I could import, but not sure if this will help this problem.
  • When a py script crashes python itself, how do you debug it?

GB

+9
source share
1 answer

That is, there are no exceptions in the journal? Does it just happen to go out in different places?

To see each statement as it is 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 these two, you can see if something in the program causes it to exit. If you do not see any evidence or patterns, then this may be something outside the program, which leads to her death.

On Linux, I would also try to run the program with help straceand watch for the OOM killer or segfaults. Not sure if such steps would be in Windows, Windows does not have an OOM killer.

+9
source

All Articles