开发者

Removing clients from the reactor in Twisted

开发者 https://www.devze.com 2023-01-24 15:43 出处:网络
I have a simple TCP client which is connected to twisted using: reactor.connectTCP(host, port, SomeClientFactory())

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 l开发者_运维知识库ike to basically:

  1. Remove the old clients
  2. Reload config
  3. 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 IConnector provider. As you can see on the definition of the IConnector interface, the disconnect method will do something like what you want. You can also use the protocol instance's transport attribute's loseConnection method, 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 like shutdown or quit or cleanup on the protocol class and then just call that.

0

精彩评论

暂无评论...
验证码 换一张
取 消