From f5b7e3e5e0dfd082e987577261c022db3bf6493d Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Thu, 5 Nov 2026 16:41:44 +0100 Subject: [PATCH] Tests: a sleep of Pyjo.Steps measured by time.monotonic of Windows before Python 3.13, a tick of 15.6 milliseconds Co-Authored-By: Claude Opus 5.5 --- t/Pyjo/Steps.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/Pyjo/Steps.py b/t/Pyjo/Steps.py index e79f099e..df6a8423 100644 --- a/t/Pyjo/Steps.py +++ b/t/Pyjo/Steps.py @@ -156,9 +156,13 @@ async def nap(seconds): value = await Sleep(seconds) return value, time.monotonic() - start + # time.monotonic of Windows before Python 3.13 counts the ticks of GetTickCount64, of 15.6 milliseconds, so a time + # that it measures may be a tick short + tick = time.get_clock_info('monotonic').resolution + value, slept = Steps(nap(0.2)).run(ua) is_ok(value, None, 'nothing, blocking') - ok(slept >= 0.2, 'slept, blocking') + ok(slept >= 0.2 - tick, 'slept, blocking') # The event loop runs the other events while the steps sleep ticks = [] @@ -169,7 +173,7 @@ async def nap(seconds): is_ok(value, None, 'nothing, non-blocking') # A timer of an event loop on libuv, as the ones of uvloop and gevent, counts whole milliseconds of a clock that # libuv rounds down, so it may be due up to a millisecond early by time.monotonic - ok(slept >= 0.19, 'slept, non-blocking') + ok(slept >= 0.19 - tick, 'slept, non-blocking') ok(len(ticks) >= 3, 'other events meanwhile') async def retried():