A rather large Python program that I write is running, but sometimes, after running for several minutes or hours, at an not easily reproducible moment, it hangs and does not display anything.
I have no idea what he is doing at that moment, and in which part of the code he is.
How can I run this in the debugger or something to see which lines of code are being executed by the program when it hangs?
Too great a value to put "printed" statements everywhere.
I did:
python -m trace --trace /usr/local/bin/my_program.py
but it gives me so much output that I don’t see anything, just millions of lines scroll on the screen.
It would be best if I could send a signal to the program "kill -SIGUSR1" or something like that, and at that moment the program will fall into the debugger and show me which line it stopped on, and maybe let me go through then the program.
I tried:
pdb usr/local/bin/my_program.py
and then:
(Pdb) cont
but what should I do to see where I am when it hangs? This does not throw an exception, it just seems that he is waiting for something, perhaps in an endless cycle.
Another detail: when the program freezes, and I press ^ C, and then (not sure if this is necessary), the program continues normally (without any exceptions and without prompting on the screen why it stopped),
source
share