On Mon, 5 May 2008 19:10:39 +0200, Terry Jones <[EMAIL PROTECTED]> wrote:
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:
deferreds.append(funcReturningDeferred(x))
dl = DeferredList(deferreds)
dl.addCallback(errorCheckingFunc)
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
error.
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?
You can do this (if you replace `pass´ with `None´, anyway) or you can
pass `consumeErrors=True´ to the `DeferredList´ initializer which will
make it do something equivalent.
Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list