[Twisted-Python] How to force synchronous behavior
Pedro Sanchez
psanchez at nortel.com
Fri Oct 28 15:40:21 MDT 2005
Hello,
I want to encapsulate deferreds into a function that looks like
synchronous when invoked. Something like this:
def mySyncFunc()
x = 0
def done(data):
global x
x = data
d = someCalculation()
d.addCallback(done)
<something here to hold until "done" is really done>
return x
print mySyncFunc()
someCalculation() returns a deferred (for instance to accesses a DB).
So, how can I write mySyncFunc() so that at the end I print the result
of someCalculation() and not just 0?
Thanks,
--
Pedro
More information about the Twisted-Python
mailing list