[Twisted-Python] Returning a Deferred as a result from another Deferred
David Reid
dreid at dreid.org
Fri Oct 5 22:05:34 EDT 2007
Hi Ryan,
On Oct 5, 2007, at 2:41 PM, Ryan Fugger wrote:
> Returning a Deferred as a result from another Deferred seems to be
> disallowed by an assertion at the start of the callback chain. Why is
> this? Right now I have worked around this limitation by wrapping my
> Deferred in a list and then unwrapping it in the callback.
The following will cause an AssertionError
d = Deferred()
d2 = Deferred()
d2.callback(d)
There isn't really a good reason to do this anyway. Since there is
likely no reason to not just return d with your callbacks attached.
If you do need two deferreds here for some reason, you _can_ return a
deferred from a callback. In which case further callbacks will not
be called until the second deferred has fired.
-David
More information about the Twisted-Python
mailing list