[Twisted-Python] Please help with Deferreds
glyph at twistedmatrix.com
Mon Aug 26 16:55:12 EDT 2002
On Mon, 26 Aug 2002 20:50:34 +0300, Tommi Virtanen <tv at twistedmatrix.com> wrote:
> On Mon, Aug 26, 2002 at 11:43:46AM +1000, Andrew Bennetts wrote:
> > That does confuse me. Somehow, if a callback has a result which is
> > another Deferred, it does something special to automatically call that
> > Deferred, which I didn't realise and seems nasty to me. I thought that
> > was only meant to happen if you explicitly called chainDeferred?
> Yes, exactly. And I'm asking why this mechanism doesn't
> work with callLater.
I'm in the process of checking in the fix for this bug. Thanks for finding it!
> > I've just re-read doc/howto/defer and I see that this is in fact
> > explained under the heading "Chain Deferreds", but I'm still curious as
> > to why this behaviour is necessary... "explicit is better than
> > implicit", etc :)
> And it can't be emulated with chainDeferred, for the simple
> reason of needing to hold both Deferreds at once. The thing
> registered with addCallback doesn't have a reference to the
> Deferred it is added to, and it could be added to many
> Plus, it allows you to use more things as callbacks; many
> information retrieval funcs return either the wanted result
> or a Deferred. They are very nice to use as callbacks,
> chaining them to retrieve values for each other.
Yes. There are actually many cases where it's not possible to use deferreds in
the way described in the "cumbersome" example you provided without changing
framework code, and that's bad. This requirement evolved from repeat
experience with those cases breaking very basic database functionality using
| <`'> | Glyph Lefkowitz: Travelling Sorcerer |
| < _/ > | Lead Developer, the Twisted project |
| < ___/ > | http://www.twistedmatrix.com |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020826/67bcb210/attachment.pgp
More information about the Twisted-Python