You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate and fix flakiness of test_final_statistics #1256
This can actually happen because the RequestProcessingRecord._last_run_at can be the same as datetime.now() called later. Which is pretty suspicions. It can happen even in the test where there is explicit 0.001s sleep, so at least in that test it should not be possible even in theory.
Seems to be happening on Windows. It is possible that system clock on Windows has worse resolution and so this would yield same time in some cases (depending in the sampling luck)
Using time.perf_counter() confirms the assumption. While the datetime.now() can still yield the same time, time.perf_counter() with better resolution can detect the change.
Activity
Pijukatel commentedon Jun 18, 2025
This can actually happen because the
RequestProcessingRecord._last_run_atcan be the same as datetime.now() called later. Which is pretty suspicions. It can happen even in the test where there is explicit 0.001s sleep, so at least in that test it should not be possible even in theory.Pijukatel commentedon Jun 18, 2025
Seems to be happening on Windows. It is possible that system clock on Windows has worse resolution and so this would yield same time in some cases (depending in the sampling luck)
Pijukatel commentedon Jun 18, 2025
Using
time.perf_counter()confirms the assumption. While thedatetime.now()can still yield the same time,time.perf_counter()with better resolution can detect the change.fix: Use `perf_counter_ns` for request duration tracking (apify#1260)