[Twisted-Python] understanding deferreds

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Jan 28 17:39:03 EST 2010


On 10:28 pm, msoulier at digitaltorque.ca wrote:
>Hello,
>
>I've been reading up on this
>
>http://twistedmatrix.com/documents/current/core/howto/defer.html
>
>I'm a bit confused as to the "visual explanation". It seems like if you 
>have a
>single callback and errback, that if the errback wants to swallow the 
>error,
>the callback will not be called at all, since deferred processing will 
>look
>for the second callback at that point by the diagram.

There are at least three ways you can have a single callback and 
errback:

   d.addCallback(cb)
   d.addErrback(eb)

or

   d.addErrback(eb)
   d.addCallback(cb)

or

   d.addCallbacks(cb, eb)

All three of these do something different.
>So, right now I'm calling my own callback from the errback if I want to
>swallow the error. Is there a better way?

It sounds like you want the middle option above.

Jean-Paul



More information about the Twisted-Python mailing list