[Twisted-Python] LoopingCall vs internet.TimerService
Hello, Thanks for twisted - very useful. Now, my questions I have written a server which accepts connections from clients, takes requests and adds them to a Queue (a python object of Queue.Queue). Now i have two approaches a) At startup, my server(a subclass of pb.Root) runs a "dispatcher" function using task.LoopingCall(dispatcher).start(0.1) b)Create a separate subclass of internet.TimerService whose function is dispatcher [INFO: dispatcher has methods like obj.callRemote, addCallback and addErrback] So which is better, neater, safer? loopingcall of timerservice? also is it safe to do the calls mentioned in INFO within dispatcher? Thank you for your time and help. Saptarshi Guha Saptarshi Guha sapsi@pobox.com
I did read the source that a)LoopingCall is implemented via calllater's b)internet.TimerService is a big wrapper around loopingcall I've probably simplified it too much but what then is the difference? thank you Saptarshi Guha On Oct 2, 2007, at 7:47 PM, Saptarshi Guha wrote:
Hello, Thanks for twisted - very useful. Now, my questions I have written a server which accepts connections from clients, takes requests and adds them to a Queue (a python object of Queue.Queue). Now i have two approaches
a) At startup, my server(a subclass of pb.Root) runs a "dispatcher" function using task.LoopingCall(dispatcher).start(0.1) b)Create a separate subclass of internet.TimerService whose function is dispatcher
[INFO: dispatcher has methods like obj.callRemote, addCallback and addErrback]
So which is better, neater, safer? loopingcall of timerservice? also is it safe to do the calls mentioned in INFO within dispatcher?
Thank you for your time and help.
Saptarshi Guha
Saptarshi Guha sapsi@pobox.com
On Tue, 2 Oct 2007 20:05:43 -0400, Saptarshi Guha <sguha@purdue.edu> wrote:
I did read the source that a)LoopingCall is implemented via calllater's b)internet.TimerService is a big wrapper around loopingcall
I've probably simplified it too much but what then is the difference? thank you
You haven't really simplified too much. They both provide the same functionality. LoopingCall provides it with one API, TimerService provides it with a different API. Of the two, LoopingCall is the more commonly useful. Jean-Paul
LoopingCall - periodically call a function. TimerService - wrapper for the twisted service with LoopingCall functionality. I use LoopingCall and write my own wrapper for the service, but TimerService is really more universal for it. More useful - create twisted Service and Plugins for your application, use component architecture this interface adaptation. In that variant you will construct TimerService from scratch =). Jean-Paul Calderone wrote:
On Tue, 2 Oct 2007 20:05:43 -0400, Saptarshi Guha <sguha@purdue.edu> wrote:
I did read the source that a)LoopingCall is implemented via calllater's b)internet.TimerService is a big wrapper around loopingcall
I've probably simplified it too much but what then is the difference? thank you
You haven't really simplified too much. They both provide the same functionality. LoopingCall provides it with one API, TimerService provides it with a different API. Of the two, LoopingCall is the more commonly useful.
Jean-Paul
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- +---------------------------------------+ |~-~-~-~-~~-~-~-~-~-~-~-~~-~-~-~-~-~-~-~| | SeNd CaKe IcE, hElLo MuMmY... | |_______________________________________|
participants (3)
-
Burus Gmail
-
Jean-Paul Calderone
-
Saptarshi Guha