[Twisted-Python] timers

Jp Calderone exarkun at divmod.com
Thu Jul 21 12:06:43 EDT 2005

On Thu, 21 Jul 2005 12:49:21 -0300, David Guaraglia <dguaraglia at gmx.de> wrote:
>I've done something very similar using just one thread for the protocol. But 
>I'm not really sure this is what you need. What I did was use a LoopingCall 
>every 2 minutes that would call a method in my protocol's factory. Everytime 
>I got a new connection (connectionMade event in the Protocol) I'd append the 
>protocol to a list in the factory, and then I'd remove it when the protocol 
>is closed.
>So the sequence is:
>1) add an empty list (connectionsList or whatever) to your factory
>2) add "self.factory.connectionsList.append(self)" in connectionMade in your 
>3) add "self.factory.connectionsList.remove(self)" in connectionLost in your 
>4) add a method that sends your "keep alive" to every connection in 
>connectionsList in your factory. (for x in self.connectionsList: 
>5) create a LoopingCall in your factory __init__.
>Maybe it's not the best solution, but it worked for me.

Where's the thread?  (Hint: not in the LoopingCall)


More information about the Twisted-Python mailing list