[Twisted-Python] serializing inline callbacks
Dustin J. Mitchell
dustin at v.igoro.us
Tue Feb 18 08:21:49 MST 2014
On Tue, Feb 18, 2014 at 10:11 AM, Axel Rau <Axel.Rau at chaos1.de> wrote:
> Thanks, but the calls in C depend on the data (program branches).
> There are 8 different call parameter sets dependent on contexts.
I still believe that making those dependencies visible is a good idea.
At any rate, in your original code:
def C(self):
...
x = self.D(...)
y = self.D(...)
z = self.D(...)
...
self.E()
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.
That's why you're seeing D execute in parallel. You're also seeing A
return before B is complete, and so on.
Dustin
More information about the Twisted-Python
mailing list