[Twisted-Python] Blocking?
Chad Rosenberg
chad at idrankwhat.net
Mon Nov 15 15:49:13 MST 2004
I've run into a problem that requires some form of blocking. I've got a
method that's compiled from a cheetah template and that gets called as the
result of a reactor callback. The cheetah method needs to be able to make
a PB call to fetch some data and block until the results arrive.
Something like this:
-----------
def reactorCallback(self):
self.callCheetahCompiledMethod()
...
def cheetahCompiledMethod(self):
print self.utilClass.lookup(foo)
...
class UtilClass:
def lookup(self, whatToLookup):
pbDeferred = self.pbCall(whatToLookup)
# Some way to block until results are gotten
return results
-----------
"cheetahCompiledMethod", itself, cannot use callbacks. The call to
"lookup" can't be done before "cheetahCompiledMethod" is called since it
is unknown at that time what "cheetahCompiledMethod" will require. I was
looking over Christopher Armstrong's gthreadless.py
(http://radix.twistedmatrix.com/archives/000099.html) and it looks
promising, but I am a little concerned about the stability of greenlets.
I also noticed twisted.trial.util.wait. What is the best way to handle
situations like this when they come up?
Thanks,
Chad
More information about the Twisted-Python
mailing list