-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Lib/test/lock_tests.py should not use time.time(), but time.monotonic() #79694
Comments
https://buildbot.python.org/all/#/builders/145/builds/956 Unhandled exception in thread started by <function Bunch.__init__.<locals>.task at 0x111775cb0>
Traceback (most recent call last):
File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 41, in task
f()
File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 591, in f
self.assertTimeout(dt, 0.1)
File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 80, in assertTimeout
self.assertGreaterEqual(actual, expected * 0.6)
File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", line 1283, in assertGreaterEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", line 719, in fail
raise self.failureException(msg)
AssertionError: -0.24049997329711914 not greater than or equal to 0.06
test_waitfor_timeout (test.test_threading.ConditionTests) ... FAIL test_waitfor_timeout():
with: def assertTimeout(self, actual, expected):
...
self.assertGreaterEqual(actual, expected * 0.6)
... It seems like time.time() gone backward on the buildbot. The test must use time.monotonic() to measure time difference. Attached PR fix the issue. |
I searched from "time.time" and "from time import(...)time" in the Python standard library (in the master branch) and it seems like all usage of time.time() are now appropriate. I close the issue. Sometimes, I'm not sure that if time.monotonic() or time.perf_counter() should be used, but at least both functions are monotonic and so are not affected by this issue (clock going backwards). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: