[Twisted-Python] Returning a Deferred as a result from another Deferred
rfugger at gmail.com
Fri Oct 5 22:46:03 EDT 2007
On 10/5/07, David Reid <dreid at dreid.org> wrote:
> 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()
> 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.
What if I need to return a Deferred from a deferToThread?
More information about the Twisted-Python