[Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Sep 30 10:42:05 EDT 2010


On 02:35 pm, chris at simplistix.co.uk wrote:
>On 30/09/2010 15:23, Phil Mayers wrote:
>>>def loop():
>>>d = maybeDeferred(doStuff)
>>>d.addErrback(partial(log.err,_why='Unhandled scheduled exception'))
>>
>>>So, how come my log.err doesn't get used for the AttributeError on
>>>connector?
>>
>>If you mean in your most recent "test_looping.py" example, it still 
>>uses
>>reactor.callLater. The call stack has gone away by the time the call 
>>is
>>made, so the exception just propagates up to the top level, where it's
>>logged.
>
>So, I appear to be back to the case where I can either gracefully 
>handle
>the exception *or* gracefully handle the errback, but not both?

No.  Absolutely, categorically wrong.

Jean-Paul



More information about the Twisted-Python mailing list