[Twisted-Python] how to write a safe catch-all

Phil Mayers p.mayers at imperial.ac.uk
Thu Sep 30 10:23:52 EDT 2010

On 30/09/10 15:13, Chris Withers wrote:
> On 30/09/2010 14:39, Jonathan Lange wrote:
>> On Thu, Sep 30, 2010 at 2:36 PM, Chris Withers<chris at simplistix.co.uk>   wrote:
>> ...
>>> Is there any way I can get both errbacks *and* exceptions handled nicely in
>>> my `loop` call?
>> You know about defer.maybeDeferred, right?
> Yep, the problem is with `loop` implemented like so:
> 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 

I honestly think a more complete example showing the real Twisted API 
that's causing you unhandled errors would help here.

More information about the Twisted-Python mailing list