[Twisted-Python] Thoughts on Deferred
Clark C. Evans
cce at clarkevans.com
Thu Mar 6 03:03:04 EST 2003
Itamar,
I had another question on Deferreds: in the comments for DeferredList it
states that an errback on the list itself won't cover errors to the list
items. I was wondering why this sort of logic wasn't implemented. I'm
asking beacuse I'm using DeferredList and this is the sort of thing that
I expected (and would want). Also, it's similar to a concern I have
with the MultiDeferred thingy that I wrote. BTW, if multi-callback
deferral is added to Deferred, then the DeferredList could just
'forward' the items from each deferred into a stream of calls...
Clark
P.S. I think I now see what you mean by cross-over. The docs for
Deferred should include the example you have below as to how to use it.
Although the explnation can be simpler:
The Deferred mechanism may be visualized as a stack of callback
and errback functions. The mechanism starts at the top of the
stack (the first function to be added), with a seed result or
exception from the function which was deferred. If the current
item is a result, the callback processing mechanism pops the
stack untill a callback is found, skipping any errbacks found
along the way. This callback can then either return a result
or throw an exception. If an exception is encountered, either
from one of the callbacks or from the initial seed, then
functions are popped off the stack until a errback is found,
skipping any intermediate callbacks. The errback is then called
with the fault, and processing continues, calling the next
errback if the errback raises an exception (or returns the
failure.Failure object).
Yes; the Deferred mechanism doesn't do "try/except" in the
_runCallbacks, but it should... so that exceptions can be
raised as well as returning failure.Failure. Yet another
patch... ;)
More information about the Twisted-Python
mailing list