Fix Docker container leak on exception and timeout#120
Merged
Jiaaqiliu merged 2 commits intoaiming-lab:mainfrom Mar 22, 2026
Merged
Fix Docker container leak on exception and timeout#120Jiaaqiliu merged 2 commits intoaiming-lab:mainfrom
Jiaaqiliu merged 2 commits intoaiming-lab:mainfrom
Conversation
Cover normal exit, timeout, unexpected exception, and keep_containers=True to verify _remove_container is always called (or skipped) as expected.
Move _remove_container into a finally block so containers are cleaned up after timeout and unexpected exceptions, not just on normal exit. Capture elapsed time before finally to exclude cleanup overhead from elapsed_sec.
2bf9c8a to
0ae7a81
Compare
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
_execute()hit a timeout or unexpected exception — only the normal exit path cleaned up_remove_containerinto afinallyblock so cleanup happens on all three exit pathselapsedbeforefinallysoelapsed_secexcludes cleanup overheadTest plan
test_cleanup_on_normal_exit— removal called on successtest_cleanup_on_timeout— both kill and removal calledtest_cleanup_on_exception— removal called on OSErrortest_keep_containers_skips_removal— removal skipped when flag set