[Twisted-Python] What is the difference in between reactor.running and reactor._stopped

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Sep 18 12:21:17 EDT 2009


On 02:23 pm, gabriel.rossetti at arimaz.com wrote:
>Hello,
>
>I tried using reactor.running for a test, to not try to stop the 
>reactor
>if it's already stopped, but it doesn't work. If I use reactor._stopped
>instead, it works. I know I'm not supposed to access it sonce it is
>prefixed by the underscore, so my question is what is the difference in
>between reactor.running and reactor._stopped, and why does
>reactor.running not work as I expect (not reactor.running ==
>reactor._stopped)?

reactor.running is really only provided for backwards compatibility.  It 
was never intended to be public.  It has bizarre semantics which you can 
read about in its unit tests:

http://twistedmatrix.com/trac/browser/trunk/twisted/internet/test/test_core.py

What you would almost certainly rather do is change your code not to 
rely on it.  Why do you find yourself needing to ask the reactor if you 
have previously asked it to stop?  Generally, your code should be able 
to keep track of that itself.

Jean-Paul



More information about the Twisted-Python mailing list