[Twisted-Python] serializing inline callbacks
Laurens Van Houtven
_ at lvh.io
Tue Feb 18 08:26:30 MST 2014
On Tue, Feb 18, 2014 at 4:21 PM, Dustin J. Mitchell <dustin at v.igoro.us>wrote:
> D is returning a Deferred, but you're not doing anything with it. In
> fact, all of A..E are returning Deferreds and you're ignoring them.
> In an inlineCallbacks-decorated method, you need to yield every
> Deferred you receive.
>
I realize you know this, but just to be clear for Axel: you only need to
yield deferreds you want to wait on. It's perfectly possible that you don't
yield a deferred but your code is still correct. E.g. let's say that you
want to wait on three ops but you do want them to execute in parallel, then
d1 = f()
d2 = g()
d3 = h()
yield gatherResults(d1, d2, d3)
is totally a thing :-)
yield in @inlineCallbacks just means "pause execution and resume when this
deferred fires".
hth
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20140218/e1b4132b/attachment-0002.html>
More information about the Twisted-Python
mailing list