[PEAK] StopIteration: Unexpected reactor exit

John Landahl john at landahl.org
Thu Mar 25 00:55:56 EST 2004


In a PEAK+Twisted app, StopIteration is being raised by 
peak.events.twisted_support.EventLoop.run_until().  The particular 
invocation of run_until() is the one called by MainLoop.run(), which 
means that its reactor.run() finished before its exitCode fired an 
event.  There are nested EventLoop.run_until() invocations in this 
scenario; one is a wrapper around the deferred returned by a 
reactor.spawnProcess(), the other around a PB call's deferred.  Shortly 
after these run and finish successfully, another reactor.spawnProcess() 
is called; *immediately* after yielding to the deferred from this 
spawnProcess(), the reactor's main loop terminates, resulting in the 
StopIteration from the original runUntil().  If I comment out both of 
the nested runUntil() invocations, no StopIteration occurs.

I seem to recall that ServiceAreas were added partly to get around some 
of the ugliness caused by Twisted's singleton reactor.  I've tried 
turning the component which calls the inner runUntils into a ServiceArea 
with its own reactor (via binding.Make(running.ITwistedReactor, 
offerAs=[running.ITwistedReactor]), for good measure), but this doesn't 
help.

I know this isn't much to go on, but perhaps it's just something simple 
I've overlooked...



More information about the PEAK mailing list