How to troubleshoot hanging script?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Aug 6 03:34:13 EDT 2008


kj a écrit :
> Hi!  I have a Pythonoob question.
> 
> I have a script that hangs indefinitely at random times; the only
> thing to do at this point is to kill it.
> 
> I'm looking for suggestions on how to troubleshoot and debug the
> problem.
> 
> I'm not even sure of where exactly the script is hanging, though
> I suspect it is right around when it tries to read from a pipe
> (generated by popen).  (I arrived at this guess by putting print
> statements all over the place, but I'm not sure this is a very
> reliable way to pinpoint the error.)
> 
> So the first thing I'd like to do is find out exactly where the
> script is hanging.  It would be nice if I could just hit Ctrl-C
> (which sends SIGINT from the terminal) when the script is hanging,
> to kill it and get a backtrace, but when this script hangs it
> becomes unresponsive to Ctrl-C! 

Pretty often, this kind of behaviour is related to a catch-all (or at 
least a 'catch-too-much') except clause that doesn't re-raise.


wrt/ debugging, there's a command-line debugger named pdb in the stdlib.



More information about the Python-list mailing list