Ticket #5552 defect closed duplicate

Opened 15 months ago

Last modified 15 months ago

accurate periodic calls

Reported by: zoranbosnjak Owned by:
Priority: normal Milestone:
Component: core Keywords: reactor, monotonic time, looping, periodic
Cc: Branch:
Author: Launchpad Bug:

Description

Twisted reactor uses python's time.time() to handle time intervals and periodic calls.

On posix (on python 2.7), this provides incorrect behaviour if the system time changes during program execution. At this situation, all pending time calculations are wrong by this time jump (which can be huge). So the program would yield completely wrong timing responses or might even stall.

The reactor shall (by default) not depend on system time, but instead on some form of monotonic time.

To workaround the problem, an application can do something like this: --- from twisted.internet import reactor from monotonic_time import monotonic_time reactor.seconds = monotonic_time ---

Example monotonic_time implementation is attached for posix platform. Not sure about other platforms.

I recommend to include monotonic time as default behaviour of the reactor.

Attachments

monotonic_time.py Download (1.0 KB) - added by zoranbosnjak 15 months ago.
example monotonic_time implementation

Change History

Changed 15 months ago by zoranbosnjak

example monotonic_time implementation

1

Changed 15 months ago by exarkun

  • status changed from new to closed
  • resolution set to duplicate

Thanks for your interest and for the sample implementation. This is a duplicate of ticket #2424, though. If you want to help out in this area of Twisted, take a look at the history over there. :)

Note: See TracTickets for help on using tickets.