[Twisted-web] How to "monitor" parallel executions of Deferreds
psanchez at nortel.com
Thu Aug 25 08:12:02 MDT 2005
Sorry, this should have gone to twisted-python instead.
I need to implement a function (say, myfunc) that fires several
independent Deferreds (using deferToThread), and that returns a deferred
itself. A client of this function (say, client) is expected to do
something like this:
print 'd1 and d2 are done'
d = myfunc()
myfuct() above does something like this:
d = defer.Deferred()
d1 = deferToThread(func1).addCallback(checkFunc1)
d2 = deferToThread(func2).addCallback(checkFunc2)
Clearly d, d1, and d2 in the above are disconnected. And I don't want to
serialize d1 and d2 which would be a way to connect them all.
The problem is I don't know how d should be defined. The idea is that
the 'done' function in the client function is only called when both
threads d1 and d2 are done.
Can you give me any suggestions on how to implement myfunc()?
More information about the Twisted-web