[PEAK] More event questions
Chad Rosenberg
chad at idrankwhat.net
Fri Nov 12 15:11:45 EST 2004
What I've got is a method compiled by a cheetah script. This method is
called as the result of a Twisted callback. The cheetah method needs to
be able to make a PB call to fetch some data and block until the data
arrives. Something like this:
-----------
def twistedCallback(self):
self.callCheetahCompiledMethod()
...
def cheetahCompiledMethod(self):
...
print self.utilClass.lookup(foo)
...
class UtilClass(binding.Component):
def lookup(self, whatToLookup):
pbDeferred = self.pbCall(whatToLookup)
# Some way to block until results are gotten
return results
-----------
"cheetahCompiledMethod", itself, cannot be asynchronous or 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. The reason I kept trying to get runUntil to work is it seemed,
at the time, like a logical choice to block on the PB call in "lookup".
My heart is not set on nested event loops, but I have yet to figure out
a way to get the above to work otherwise. :(
- Chad
On Fri, 12 Nov 2004, Phillip J. Eby wrote:
> At 03:26 PM 11/11/04 -0800, Chad Rosenberg wrote:
>
> >Is it safe to use runUntil from a call originating from reactor.callLater?
>
> Not with the same reactor instance.
>
>
> >I thought this would eliminate nested runUntils, but I am still getting
> >Unexpected reactor exits. Any insights?
>
> Yes. Stop using runUntil(). I haven't seen any examples or explanations
> from you that show you actually need it for anything. 'runUntil()' is
> intended for a top-level event loop. Code that is inside an event loop
> should not use it unless you need a nested event loop. If you can explain
> why you need a nested event loop, I'll help you figure out how to get it
> accomplished.
>
> Most likely, however, whatever you're trying to do will more easily be
> accomplished by yielding to an event, or setting an event callback.
>
> _______________________________________________
> PEAK mailing list
> PEAK at eby-sarna.com
> http://www.eby-sarna.com/mailman/listinfo/peak
>
More information about the PEAK
mailing list