handling uncaught exceptions with pdb?

R. Bernstein rocky at panix.com
Fri Sep 12 05:20:05 EDT 2008


"Diez B. Roggisch" <deets at nospam.web.de> writes:

> R. Bernstein schrieb:
>> Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
>>
>>> I think I've asked about this before, but is there a way to set up
>>> Python to handle uncaught exceptions with pdb?  I know about setting
>>> sys.except_hook to something that calls pdb, but this is normally done
>>> at the outer level of a program, and by the time that hook gets
>>> called, the exception has already unwound the stack to the outermost
>>> level.  My situation is I run a multi-hour or multi-day computation
>>> that eventually crashes due to some unexpected input and I'd like to
>>> break to the debugger at the innermost level, right when the exception
>>> is encountered, so I can fix the error with pdb commands and resume
>>> processing.  
>> ...
>>
>> Why not use the traceback you get to show you where to change the code
>> around that point to add an exception handler there which calls the
>> debugger?
>
> Because he wants to fix the issue directly in-place, and then
> continue, instead of losing hours or even days of computation.

Then proactively add exception handlers ;-)



More information about the Python-list mailing list