Fix flaky test_kick_scan_is_idempotent (drain scan threads)#13
Merged
cryptopoly merged 1 commit intomainfrom Apr 29, 2026
Merged
Fix flaky test_kick_scan_is_idempotent (drain scan threads)#13cryptopoly merged 1 commit intomainfrom
cryptopoly merged 1 commit intomainfrom
Conversation
Race in test_kick_scan_is_idempotent: tearDown's tmp.cleanup() ran while a daemon library-scan thread was still writing library_cache.json into the tmpdir, yielding OSError [Errno 39] Directory not empty. Track spawned scan threads on ChaosEngineState and add a shutdown() method that joins them. Tests now drain the state before cleaning up the tmpdir, eliminating the race.
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
tests/test_state_async_library.py::AsyncLibraryScanTests::test_kick_scan_is_idempotentcaused intermittent CI failures (OSError: [Errno 39] Directory not empty)._kick_library_scanhad no handles, sotearDown'stmp.cleanup()could rmtree the tmpdir while a thread was still writinglibrary_cache.json.Fix
ChaosEngineStateand prune dead entries on each kick.ChaosEngineState.shutdown(timeout=5.0)that joins all alive scan threads.self.stateand drain it intearDownbeforeself.tmp.cleanup().Verification
tests/test_state_async_library.pynow deterministic locally (5/5 runs).pytestgreen on Linux runner via run 25129383727 (test job + 3-OS build matrix all ✓).npx tsc --noEmitclean.npm test179/179 pass.Test plan