Repository navigation
tests: don't time the SSL session cache deadline test with sleep - #1099
Merged
Merged
Conversation
test_the_same_session_again_keeps_the_deadline_it_had stored a 50 ms deadline, slept 60 ms and expected the entry gone. On Windows before Python 3.13, time.monotonic() advances in 15.625 ms ticks, so 60 ms of sleep can read as 46.9 ms and the entry is still returned. Store the first session already expired instead, as the neighbouring tests do. Re-storing the same session must keep that deadline, so the lookup still has to miss; no clock is involved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 27 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
roydahan
approved these changes
Oct 6, 2026
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.
test_the_same_session_again_keeps_the_deadline_it_hadfails intermittently in the Windows wheel builds, e.g. on #1089 (job, cp310-win_amd64):Cause: the test stores a 50 ms deadline, sleeps 60 ms and expects the entry to have expired. On Windows before Python 3.13,
time.monotonic()advances in 15.625 ms ticks, so after 60 ms of sleep the clock can read only 46.9 ms later, short of the deadline. @roydahan analysed this in a comment on #1052 and measured a 14% failure rate with a quantized clock.Fix: store the first session already expired (
lifetime=-1), as the neighbouring tests do, and drop the sleep. Re-storing the same session must keep the expired deadline, so the lookup still has to miss, with no clock involved. Thetimeimport is now unused, so it goes too.Tests:
pytest tests/unit/test_ssl_session_cache.pypasses (31 tests). Withset()changed to give a re-stored session a fresh deadline, this test fails, so it still guards what it's meant to.🤖 Generated with Claude Code