[Twisted-Python] DeferredList and errbacks
andrew-twisted at puzzling.org
Tue Apr 5 20:02:12 EDT 2005
On Tue, Apr 05, 2005 at 04:13:36PM -0700, Lenny G Arbage wrote:
> I just noticed [what appears to me to be] a
> contradiction in the twisted documentation. The
> "Using Deferreds" howto  says, "A standard
> DeferredList will never call errback," while the
> "Twisted FAQ"  states, "Always add errbacks!" in
> response to the question, "My Deferred or DeferredList
> never fires, so my program just mysteriously hangs!
> What's wrong?"
> So, which is it?
> I suppose what this is getting at is that each
> deferred in a DeferredList should have an errback
> attached separately, but this isn't super-clear to me.
> Is this the right way to interpret the above
By default, DeferredList waits for all its Deferreds to fire (with a result
or an error), and returns a big list of results of the form:
[(success_bool, value), (success_bool, value), ...]
Where 'success_bool' is True if the corresponding Deferred succeeded (i.e.
fired a callback), and False if it failed (i.e. fired an errback). 'value'
will be a result or a Failure instance accordingly. So a standard
DeferredList will never call errback, because it includes errors in the
result passed to its callback.
Error handling in this case could be handled by the user of the
DeferredList, because it would have access to any underlying failures via
the callback. But you're correct, the original deferreds would still need
errbacks attached -- or pass consumeErrors=True to DeferredList, and it will
do this for you.
And of course, the situation is a bit different again if you pass
You're right that the docs are a bit confusing here. Please file a bug
about it at http://twistedmatrix.com/bugs. The "Other Behaviours" section
of http://twistedmatrix.com/documents/current/howto/defer tries to address
this, but perhaps we could do better.
More information about the Twisted-Python