Repository navigation
Commit 1d4ae41
authored
test: fix flaky test_crawler_intermediate_statistics on Windows (#2265)
`test_crawler_intermediate_statistics` failed on Windows 3.12
([run](https://github.com/apify/crawlee-python/actions/runs/36837667765/job/110288921245?pr=2263))
with `98582 µs >= 100000 µs`. The test sleeps 100 ms with
`asyncio.sleep` and expects `crawler_runtime` to be at least that long,
but `crawler_runtime` comes from `datetime.now()`. On Windows before
Python 3.13 that clock ticks every ~15.6 ms, and the only slack in the
test was the poll lag, which can be close to zero.
The test now takes its own `datetime.now()` readings when it sees the
crawler start and after the sleep, and asserts the runtime is at least
the gap between them. Both sides use the same clock, and the check still
fails if the runtime isn't updated while the crawler runs.
*✍️ Drafted by Claude Code*1 parent ce96578 commit 1d4ae41
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
2446 | 2446 | | |
2447 | 2447 | | |
2448 | 2448 | | |
| 2449 | + | |
2449 | 2450 | | |
2450 | | - | |
| 2451 | + | |
| 2452 | + | |
2451 | 2453 | | |
| 2454 | + | |
2452 | 2455 | | |
2453 | | - | |
| 2456 | + | |
| 2457 | + | |
2454 | 2458 | | |
2455 | 2459 | | |
2456 | 2460 | | |
| |||
0 commit comments