[Twisted-Python] timers

David Guaraglia dguaraglia at gmx.de
Thu Jul 21 13:03:13 EDT 2005

LOL! (lols allowed here? or just not allowed as in #twisted?). Don't 
know why I used the word "thread" in there... I was just going to 
describe something I had made, then I remembered I had corrected it 
using a LoopingCall.


Jp Calderone wrote:

> On Thu, 21 Jul 2005 12:49:21 -0300, David Guaraglia 
> <dguaraglia at gmx.de> wrote:
>> Andrzej,
>> 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 protocol
>> 3) add "self.factory.connectionsList.remove(self)" in connectionLost 
>> in your protocol
>> 4) add a method that sends your "keep alive" to every connection in 
>> connectionsList in your factory. (for x in self.connectionsList: 
>> x.sendKeepAlive())
>> 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)
> Jp
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list