[Twisted-Python] LineReceiver Protocol

Michael Mata michael.mata at gaigen.net
Sun Nov 21 20:36:12 EST 2004


Michael Mata wrote:

> Christopher Armstrong wrote:
>
>> On Sat, 20 Nov 2004 23:12:18 -0800, Michael Mata
>> <michael.mata at gaigen.net> wrote:
>>
>>> Is there a way to extend the LineReceiver protocol to take action on a
>>> continued, periodic basis?  Currently, the protocol only does work 
>>> when a line is received.  However, there are times when the script 
>>> should
>>> take action without waiting to receive a line.
>>
>>
>>
>> It doesn't have anything to do with the protocol; what you want is
>> reactor.callLater(seconds, functionToCall)
>>
>> http://twistedmatrix.com/documents/current/howto/time has more 
>> information.
>
> The function task.LoopingCall(runEverySecond) from twisted.internet 
> looks like a good fit for scheduling recurring maintenance.

Where should task.LoopingCall(runEverySecond) be placed?

I'm currently using internet.TCPServer, which is passed the port number 
and a protocol factory.  The protocol inherits from basic.LineReceiver.  
I tried placing the task in the factory's __init__ function, but it 
doesn't seem to run.






More information about the Twisted-Python mailing list