How to know reactor is running or not in python?
python, python-2.7, reactor, twisted, twisted.internet
Solution
You do not state which reactor you are using, but this page says `ReactorBase` is the base class for Reactors.
Also on the same page, it mentions an instance variable `running` that is further explained here.
It says
running = A bool which is True from during startup to during shutdown and False the rest of the time.
With that information we can change your code to:
if reactor.running:
# do some work
Problem
How to know reactor status (running or not) ? I tried this(searched from google): ``` from twisted.internet import reactor if reactor.callWhenRunning(lambda: None) is not None: # do some work ``` It worked, but this seems like weird way. What can be other ways of doing this ?