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

Chris Satterthwaite chris at cmsconstruct.com
Fri Mar 22 17:26:24 MDT 2019


Hi Chris,

The files I attached (with the full classes) made it through to my email, but I wondered if they would they go through to everyone.

Here's a gist with the same scripts:
https://gist.github.com/codingadvocate/f732da79ddf6cef4b7a0b6b3679f519f

And yep, as you mentioned, a 'sleep' is definitely blocking.  That's not in the production version; I just dropped it in here for the test script to simulate something.

Thanks!
-Chris

-----Original Message-----
From: Twisted-Python <twisted-python-bounces at twistedmatrix.com> On Behalf Of Chris Withers
Sent: Friday, March 22, 2019 1:54 PM
To: twisted-python at twistedmatrix.com
Subject: Re: [Twisted-Python] stop/start client connections with loseConnection in ReconnectingClientFactory

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

_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




More information about the Twisted-Python mailing list