Skip to content

Fix flaky test_task_duration_is_measured on Windows#345

Merged
chrisguidry merged 2 commits intomainfrom
fix-duration-test-flake
Feb 18, 2026
Merged

Fix flaky test_task_duration_is_measured on Windows#345
chrisguidry merged 2 commits intomainfrom
fix-duration-test-flake

Conversation

@chrisguidry
Copy link
Owner

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.).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

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>
@github-actions
Copy link

github-actions bot commented Feb 18, 2026

📚 Documentation has been built for this PR!

You can download the documentation directly here:
https://github.com/chrisguidry/docket/actions/runs/22142423132/artifacts/5556215526

@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a63b5f3) to head (450cd74).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #345   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           99        99           
  Lines         3097      3098    +1     
  Branches        27        27           
=========================================
+ Hits          3097      3098    +1     
Flag Coverage Δ
cli-python-3.10 100.00% <ø> (ø)
cli-python-3.11 100.00% <ø> (ø)
cli-python-3.12 100.00% <ø> (ø)
cli-python-3.13 100.00% <ø> (ø)
cli-python-3.14 100.00% <ø> (ø)
python-3.10 100.00% <100.00%> (ø)
python-3.11 97.99% <100.00%> (-0.04%) ⬇️
python-3.12 100.00% <100.00%> (ø)
python-3.13 100.00% <100.00%> (ø)
python-3.14 100.00% <100.00%> (ø)
windows-python-3.10 100.00% <100.00%> (ø)
windows-python-3.11 97.90% <100.00%> (+<0.01%) ⬆️
windows-python-3.12 100.00% <100.00%> (ø)
windows-python-3.13 100.00% <100.00%> (ø)
windows-python-3.14 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/instrumentation/test_export.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
@chrisguidry chrisguidry merged commit 2865453 into main Feb 18, 2026
92 of 93 checks passed
@chrisguidry chrisguidry deleted the fix-duration-test-flake branch February 18, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments