[PEAK] Events Question: How bad of an idea is this?
chad at idrankwhat.net
Wed Nov 10 19:24:09 EST 2004
The code I have been working on uses quite a bit of generators wrapped by
taskFactory and I am finding it increasing necessary to be able to call a
variety of other nested methods from those generators that make calls
involving Twisted Deferreds and EventLoop.runUntil in twisted_support.py.
Take, for instance, this sample code:
from peak.api import binding, commands, events
eventLoop = binding.Obtain(events.IEventLoop)
reactor = binding.Obtain(commands.ITwistedReactor,
yield self.eventLoop.sleep(4); events.resume()
daemon = binding.Make(events.taskFactory(daemon))
something = binding.Make(something)
When I run the above example with Peak 0.5a3 under Gentoo Linux and
Python 2.3.3 I get a "StopIteration: Unexpected reactor exit" in
"peak/events/twisted_support.py", line 191, in runUntil.
Trying to get it to work, I made the following change to
EventLoop.runUntil in twisted_support.py:
if not exit:
-- to --
while not exit:
With this change the above sample code runs to completion without any
errors, as does the code I am working with. I'm not sure of what, if any,
long term repercussion this may produce (stack overflows, infinite loops,
etc). Hence my question, how bad of an idea is this?
More information about the PEAK