bakwc/PySyncObj

Use steady clock instead of time.time

JustAnotherArchivist opened this issue · 1 comments

PySyncObj currently uses time.time throughout its code for time measurements and timeout calculation. But time.time just returns the system time. If the system time changes while PySyncObj is running, timeouts may be triggered earlier or later than expected, which could have nasty consequences.

Unfortunately, it seems that there is no easy way to fix this. Python 3.2 and up has time.monotonic, but this is only monotonic, not steady, i.e. it can still be affected by NTP's clock skewing, and if the difference between two calls of that method is 1, the actual time difference between the calls is still not guaranteed to actually be 1 second. There is a CLOCK_MONOTONIC_RAW on Linux, but I don't know what the situation on other OS is. There'd also have to be a solution for Python 2.7 as long as that's still supported by PySyncObj.

bakwc commented

Fixed by #114