[Twisted-Python] Counting errors in a DeferredList and avoiding Unhandled error in Deferred messages

Terry Jones terry at jon.es
Mon May 5 11:10:39 MDT 2008

If I pass a list of deferreds to DeferredList and want to add a callback to
the DeferredList to look at whatever errors have occurred in the underlying
deferreds, should I do something like this:

  deferreds = []
  for x in whatever:

  dl = DeferredList(deferreds)

  for d in deferreds:
    d.addErrback(lambda _: pass)

This ensures that errorCheckingFunc gets defer.FAILURE for those deferreds
that finished up in their errback chain. Adding the lambda _: pass errback
to each deferred in deferreds after it has been passed to DeferredList
makes sure the errback chain doesn't later reach its end with an unhandled

It that the right/best/approved way to handle needing to deal with errors
in the callback of a DeferredList and not trigger the "Unhandled error in
Deferred" message?


More information about the Twisted-Python mailing list