I have a simple TCP client which is connected to twisted using:
reactor.connectTCP(host, port, SomeClientFactory())
The program is able to receive a HUP signal to trigger a reload. I’d like to basically:
- Remove the old clients
- Reload config
- Create new clients based upon new config
However, I can’t seem to find a way to acheive the first of these points. Any tips?
Thanks
IReactorTCP.connectTCP returns an
IConnectorprovider. As you can see on the definition of theIConnectorinterface, thedisconnectmethod will do something like what you want. You can also use the protocol instance’s transport attribute’sloseConnectionmethod, of course. The latter would be more suitable if there’s any kind of cleanup you want the protocol to do before actually disconnecting, since you could put that work and a call to loseConnection at the end of a method likeshutdownorquitorcleanupon the protocol class and then just call that.