[Twisted-Python] stop/start client connections with loseConnection in ReconnectingClientFactory

Chris Withers chris at withers.org
Fri Mar 22 12:54:24 MDT 2019


On 22/03/2019 17:08, Chris Satterthwaite wrote:
>                  def clientConnectionLost(self, connector, reason):

Without the rest of your class, it's difficult to see some of the 
potential problems... Could you put it on a gist somewhere?

> 
>                                  print('  factory clientConnectionLost: 
> reason: {}'.format(reason))
> 
>                                  # if self.disconnectedOnPurpose:
> 
>                                  #             ## Hack to keep reactor alive
> 
>                                  #             print('  factory 
> clientConnectionLost: increasing numPorts')
> 
>                                  #             self.numPorts += 1
> 
>                                  #             self.numPortsChanged = True
> 
>                                  #             
> self.disconnectedOnPurpose = False
> 
>                                  print('  ... simulate client going idle 
> before attempting restart...')
> 
>                                  time.sleep(5)

This will block the reactor, so don't think you should be doing it...

cheers,

Chris




More information about the Twisted-Python mailing list