If I create multiple clients by doing this:
def main():
clients = [None]*10
for i in range(0, 10):
clients[i] = ClientFactory()
reactor.connectTCP('192.168.0.1', 8000, clients[i])
reactor.run()
How to I -gracefully- stop the reactor? If I do:
self.transport.loseconnection()
In the protocol, then do:
reactor.stop()
In the factory, then the next client is going to try to come along a stop the reactor again. However, this of course leads to the error:
Can't stop a reactor that isn't running
How can I gracefully stop the reactor in such a scenario?