[Twisted-Python] accurate periodic call

gelin yan dynamicgl at gmail.com
Mon Feb 20 01:08:46 EST 2012

On Mon, Feb 20, 2012 at 12:14 PM, Itamar Turner-Trauring <
itamar at itamarst.org> wrote:

> On 02/19/2012 11:49 AM, Zoran Bošnjak wrote:
> > Hello all,
> > I was astonished to find out that looping call period depends on the
> system time by default. The periodic tick can even stall for a long time,
> if the system time jumps backwards during program execution. It turned out
> that this is in fact a python problem (not providing a monotonic time, at
> least not for posix).
> >
> > I urgently need accurate periodic call in my program and I've found the
> solution below that seems to be working. I kindly ask you for your comments:
> > - Is this monotonic_time implementation OK from python perspective?
> I didn't read it in detail, but it seems vaguely plausible; overriding
> reactor.seconds is the thing to do.
> > - Is monkey patch to the reactor OK or is there any other solution more
> appropriate in this case (I do not want to patch each looping call, but
> once in the application)?
> That's probably the easiest in this situation.
> > - Does this patch have any negative influence to the rest of the reactor?
> Everything is *supposed* to use reactor.seconds - grep for time.time and
> see if it shows up anywhere in twisted.internet.
> > - How would you implement a periodic function call in twisted
> application (as accurate as possible)?
> LoopingCall if you had this patch.
> > - Any chance to see something implemented inside twisted and/or python,
> so that applications don't need this kind of tricks?
> >
> See http://twistedmatrix.com/trac/ticket/2424 - using ctypes is probably
> easier than the C extension the included patch provides.
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Does it work on windows??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20120220/252dc404/attachment.htm 

More information about the Twisted-Python mailing list