Sorry for the vague title, but I couldn't figure out something better.
Are there any ways to get the current status of the reactor in twisted? By status I mean:
- Listeners on ports
- Connected protocols
- Deferreds that are waiting to be fired
- LoopingCalls that are running
- Threads that are "idle"
- and other "active" stuff...
Basically I'm trying to figure out if the reactor is just sitting idly. The question itself is broader than what I actually need to do, for the sake of completeness for stackoverflow.
Now, my current situation is as follows:
I'm using someone else's script that listens on many "dynamic" ports that are selected by this person's script, so I can't just use my script to do something like listenTCP, or TCP4ServerEndpoint and check the status of it. This is somewhat similar to non-PASV FTP where each listening port is discarded after each use. The other problem is that my own little program is also running in the same process, which I use it as an argument to start his program. It's basically an interface to his program. When all his things are done AND my things are done as well, I want to shutdown the reactor. Thus I'm trying to figure out when I can stop the reactor. My exact condition to shutdown is as follow:
- Only listening on 1 port, and no other.
- No deffereds nor loopingCalls that are gonna fire.
I searched but only found things like "if reactor.running" or Stop twisted reactor on a condition, which needs to keep track by using flags. I would rather not touch his code. If it's something that could contribute to twisted, I'd much rather do that. But if there is already an alternative, I'd rather not re-invent the wheel.
Does his script need to be changed so it notifies my script of these conditions?