[Twisted-Python] Re: Making DeferredList look like Deferred
Thomas HERVE therve at free.fr wrote:
def iterfail(err, i): print " %i failed" % i
The problem is here. You add an errback to your defer, but you stop the error propagation by not returning err. Either do 'return err' or not 'addErrback(iterfail)'.
Thomas, thanks for the response. I thought that
might be it, but no avail. If I 'return err' in
iterfail, I get:
in testdlist
deferred will fail in 2s
deferred will succeed in 2s
0 failed
failed: testdlist
Unhandled error in Deferred:
Traceback (most recent call last):
Failure:
Quoting Lenny G Arbage
Thomas, thanks for the response.
You're welcome :).
I thought that might be it, but no avail. If I 'return err' in iterfail, I get:
[snip]
Unhandled error in Deferred:
That's expected behaviour.
I don't know why the error is unhandled in either case -- the DeferredList has an errback set. (If I raise a new error in iterfail, the same result occurs, naturally). It also doesn't seem to matter whether I add 'fireOnOneErrBack' to the DeferredList constructor or not. Any ideas? Does this code behave differently on your machine?
The behaviour you want is provided by the option 'consumeErrors' of DeferredList (you can see why here : http://twistedmatrix.com/projects/core/documentation/howto/defer.html#auto8). -- Thomas
participants (2)
-
Lenny G Arbage
-
Thomas HERVE