Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions t/Pyjo/Steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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():
Expand Down
Loading