Skip to content

Commit e2d7069

Browse files
authored
test: Increase sleep tolerance in request_max_duration test for Windows CI (#1827)
## Summary - Increase `asyncio.sleep` from 50ms to 200ms and tolerance from 15ms to 50ms in `test_request_max_duration_tracks_maximum` to fix flaky failures on Windows CI where timer resolution is ~15ms. ## Context - [Failed run](https://github.com/apify/crawlee-python/actions/runs/23786266607/job/69310149225?pr=1823) — `asyncio.sleep(0.05)` only slept ~34ms on Windows, falling below the `0.035s` threshold.
1 parent 41c21b7 commit e2d7069

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/unit/_statistics/test_request_max_duration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
async def test_request_max_duration_tracks_maximum() -> None:
99
"""Test that request_max_duration correctly tracks the maximum duration, not the minimum."""
1010

11-
# asyncio.sleep() can sleep slightly shorter than expected https://bugs.python.org/issue31539#msg302699
12-
asyncio_sleep_time_tolerance = 0.015
13-
sleep_time = 0.05
11+
# asyncio.sleep() can sleep significantly shorter than expected on Windows due to poor timer resolution
12+
# https://bugs.python.org/issue31539#msg302699
13+
asyncio_sleep_time_tolerance = 0.05
14+
sleep_time = 0.2
1415

1516
async with Statistics.with_default_state() as statistics:
1617
# Record a short request
@@ -20,7 +21,7 @@ async def test_request_max_duration_tracks_maximum() -> None:
2021

2122
# Record a longer request
2223
statistics.record_request_processing_start('request_2')
23-
await asyncio.sleep(sleep_time) # 50ms delay
24+
await asyncio.sleep(sleep_time) # 200ms delay
2425
statistics.record_request_processing_finish('request_2')
2526
second_duration = statistics.state.request_max_duration
2627

0 commit comments

Comments
 (0)