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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With