-
-
Notifications
You must be signed in to change notification settings - Fork 32k
test_asyncio.test_base_events: test_time_and_call_at() failed on GHA Windows x64 #110695
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
Comments
This happens because on windows it uses a lower precision clock, I once worked on a PR to use a higher precision clock but it was rejected in the hopes that by default monotonic would use higher precision clock but I don't think this it was ever implemented. I still think we should just change |
If you two (@vstinner and @kumaraditya303) agree, I will also agree to that proposal. |
Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms.
Maybe asyncio could do better to not miss so many clock ticks, but I'm not really interested to enhance asyncio accuracy on Windows. So I wrote PR #110952 to simply restore test_asyncio to its previous status quo, before commit db0a258: tolerate 50 ms difference. |
…GH-110952) Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms. (cherry picked from commit 9a9fba8) Co-authored-by: Victor Stinner <vstinner@python.org>
Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms.
…GH-110952) Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms. (cherry picked from commit 9a9fba8) Co-authored-by: Victor Stinner <vstinner@python.org>
…#110952) Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms.
…#110952) Before utils.CLOCK_RES constant was added (20 ms), test_asyncio already used 50 ms.
Uh oh!
There was an error while loading. Please reload this page.
Recently, I modified asyncio tests to add a CLOCK_RES constant. Example of test_time_and_call_at() change:
So the test now tolerates only 20 ms difference instead of 50 ms. Problem, the test failed on GHA Windows x64 CI :-(
asyncio uses
time.monotonic()
asloop.time()
. test.pythoninfo reports a clock resolution of 15.6 ms.call_at() creates a TimerHandle .
_run_once()
usesself._scheduled[0]._when - self.time()
timeout to callself._selector.select(timeout)
. asyncio usesself._clock_resolution = time.get_clock_info('monotonic').resolution
to decide in_run_once()
if an event should be scheduled or not.Maybe there is a rounding issue and sometimes a callback scheduled in 100 ms is actually run in 78 ms.
A timeout of 100 ms should wait 6 or 7 monotonic clock ticks, whereas 78 ms is around 5 clock ticks:
The test reads the clock twice, maybe t0 is 1 tick ahead of when:
It seems like the callback was called 2 ticks before the expected timeout when taking rounding issue in account:
The callback should be called between 78.1 ms (2 clicks before) and 109.4 ms (1 click after). It would be nice to only have an error of a maximum of 1 click:
Between 93.8 ms (1 click before) and 109.4 ms (1 click after).
I'm not sure what's going on.
GHA Windows x64:
test.pythoninfo:
build: https://github.com/python/cpython/actions/runs/6477453109/job/17587684818?pr=110677
cc @sobolevn @kumaraditya303
Linked PRs
The text was updated successfully, but these errors were encountered: