Fix flaky test_task_duration_is_measured on Windows#345
Merged
chrisguidry merged 2 commits intomainfrom Feb 18, 2026
Merged
Conversation
The test calibrated asyncio.sleep(0.1) outside the task and used that to bound the duration measured inside the task. Each sleep varies independently, so the calibration didn't predict the task's actual sleep — Windows CI on #344 hit this (calibration got 125ms, task only slept 93ms). Instead, the task now captures its own elapsed time and the assertion uses that directly: the worker's duration must be at least the inner sleep and no more than 2x (headroom for dep injection, serialization, etc.). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
📚 Documentation has been built for this PR! You can download the documentation directly here: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #345 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 99 99
Lines 3097 3098 +1
Branches 27 27
=========================================
+ Hits 3097 3098 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The worker measures task duration with time.time(), but the test's inner timing used time.monotonic(). On Windows these are different clocks with different resolutions, so inner_elapsed can exceed the worker's duration measurement — exactly what happened in CI (94ms vs 87ms). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The test calibrated
asyncio.sleep(0.1)outside the task and used that tobound the duration measured inside the task. Each sleep varies
independently, so the calibration didn't predict the task's actual sleep
— Windows CI on #344 hit this (calibration got 125ms, task only slept
93ms).
Instead, the task now captures its own elapsed time and the assertion
uses that directly: the worker's duration must be at least the inner
sleep and no more than 2x (headroom for dep injection, serialization,
etc.).
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com