[Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]
p.mayers at imperial.ac.uk
Thu Sep 30 10:53:05 EDT 2010
On 30/09/10 15:35, Chris Withers 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
>> 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
> 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?
It should be possible if using Twisted APIs correctly to reliably
If it is not, that is a Twisted bug (or possibly API limitation)
However, your "test_looping.py" is not using the API correctly; the
reactor.callLater throws away the call stack, so the error has nowhere
Since you're not using reactor.callLater in your real code, the example
is not valid. Hopefully I'm being more clear here!
>> I honestly think a more complete example showing the real Twisted API
>> that's causing you unhandled errors would help here.
> Unfortunately, you neither want to see, nor am I allowed to publish to a
> mailing list, that several hundred lines of proprietary code I'd need to
I suspected as much.
I don't think I can help I'm afraid; maybe other more experience people
can spot the error from the tracebacks. Sorry I couldn't be more useful.
More information about the Twisted-Python