Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use time.monotonic() for calculating timeouts. #136

Merged
merged 4 commits into from
Feb 16, 2022

Conversation

avian2
Copy link
Contributor

@avian2 avian2 commented Feb 16, 2022

time.time() is affected by system clock updates (for example, by the NTP
daemon). This can cause timeouts to be unpredictable if clock jumps forwards or
backwards while code is waiting to acquire a lock.

time.monotonic() returns a time value that is not affected by clock updates and
does not have this issue. In Python 3.5 and later it is available on all systems[1].

[1] https://docs.python.org/3/library/time.html#time.monotonic

time.time() is affected by system clock updates (for example, by the NTP
daemon). This can cause timeouts to be unpredictable if clock jumps forwards or
backwards while code is waiting to acquire a lock.

time.monotonic() returns a time value that is not affected by clock updates and
does not have this issue. In Python 3.5 and later it is available on all systems[1].

[1] https://docs.python.org/3/library/time.html#time.monotonic
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a changelog entry too?

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat gaborbernat merged commit 46e4d0b into tox-dev:main Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants