test: fix flaky test_autoclean_folder#34
Merged
Conversation
test_autoclean_folder intermittently failed on CI ("True is not false"): it
created a folder, started the background autoclean timer, then asserted the
folder was gone after a fixed time.sleep(0.020). On a loaded runner the cleanup
thread hadn't necessarily run within 20ms.
Replace the fixed sleep with active polling (wait up to 2s for the folder to
disappear). The autoclean still deletes it well within that window; the test is
now deterministic. No production code changed.
Co-Authored-By: Claude Opus 4.8 <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.
Summary
Stabilises
user_file_storage_test.py::TestUserFileStorage::test_autoclean_folder, which intermittently failed on CI (most recently Python 3.11, PR #33) with:Root cause
The test creates a folder, starts the background autoclean timer, then asserts the folder is gone after a fixed
time.sleep(0.020). The cleanup runs on athreading.Timer; on a loaded runner it hasn't necessarily executed within 20 ms, so the folder may still exist when the assertion runs.Fix (test-only)
Replace the fixed sleep with active polling — wait up to 2 s for the folder to disappear, then assert. The autoclean (lifetime 2 ms, timer period ~0.08 ms) deletes it far within that window, so the test is deterministic without being timing-fragile.
Testing
This was the third and last timing-flaky tracked this cycle (after the
tests_tempcleanup race and the PTY env read race, both already fixed).🤖 Generated with Claude Code