[Twisted-Python] Deterministic TimerService
Hi, Thanks for such a useful framework. While working on an industrial data logger using Twisted, I found that application.internet.TimerService calls my own callLater callable function before reissuing the next callLater. Consequently, instead of a time period c, the callable function runs every c+x, where x is the duration of my own function, and thus appears to slip over time. Based on my past experiences with DEC RSX "mark time" and VMS "set timer" in similar situations, I recommend changing: def setupCall(): self.callable(*self.args, **self.kwargs) self._call = reactor.callLater(self.step, setupCall) to def setupCall(): self._call = reactor.callLater(self.step, setupCall) self.callable(*self.args, **self.kwargs) Reissuing the timer request first appears to work more as I'd expect, particularly as I am using timestamp information for each scan to compute an appropriate bsddb record number in a persistent circular buffer. Any other opinions? Regards, Norm Petterson
On Thu, 2004-03-04 at 11:08, Norm Petterson wrote:
While working on an industrial data logger using Twisted, I found that application.internet.TimerService calls my own callLater callable function before reissuing the next callLater. Consequently, instead of a time period c, the callable function runs every c+x, where x is the duration of my own function, and thus appears to slip over time.
TimerService in 1.2.0 uses twisted.internet.task.LoopingCall internally, which deals with this a bit better. Try upgrading and tell us if it solves your problem? -- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
On Thu, 2004-03-04 at 11:08, Norm Petterson wrote:
While working on an industrial data logger using Twisted, I found that application.internet.TimerService calls my own callLater callable function before reissuing the next callLater. Consequently, instead of a time
Yup, the 1.2.0 TimerService runs like a Swiss watch (no apparent time slippage at all). Thanks. I'll remember to check the latest version in the future ;-)... ----- Original Message ----- From: "Itamar Shtull-Trauring" <itamar@itamarst.org> To: <twisted-python@twistedmatrix.com> Sent: Thursday, March 04, 2004 11:43 AM Subject: Re: [Twisted-Python] Deterministic TimerService period
c, the callable function runs every c+x, where x is the duration of my own function, and thus appears to slip over time.
TimerService in 1.2.0 uses twisted.internet.task.LoopingCall internally, which deals with this a bit better. Try upgrading and tell us if it solves your problem?
-- Itamar Shtull-Trauring http://itamarst.org Looking for a job: http://itamarst.org/resume.html
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Hello,
While working on an industrial data logger using Twisted, I found that application.internet.TimerService calls my own callLater callable function before reissuing the next callLater. Consequently, instead of a time period c, the callable function runs every c+x, where x is the duration of my own function, and thus appears to slip over time.
I never used this feature but, for what it is worth, I agree with what you are saying . However I recall a nasty side effect that this behaviour had. If your callback are taking all the CPU and can not finish before the new callback is scheduled, it will cause the box to hit more and more CPU and memory until something bad happens. I think that an adding an optional flag to not allow the new callback to run if the previous one is not completed would be a good idea. My $.02 as I do not have any code to contribute. Thomas
participants (3)
-
Itamar Shtull-Trauring -
Norm Petterson -
Thomas Mangin