Skip to content

Fix Docker container leak on exception and timeout#120

Merged
Jiaaqiliu merged 2 commits intoaiming-lab:mainfrom
miky-rola:docker-container-leak
Mar 22, 2026
Merged

Fix Docker container leak on exception and timeout#120
Jiaaqiliu merged 2 commits intoaiming-lab:mainfrom
miky-rola:docker-container-leak

Conversation

@miky-rola
Copy link
Contributor

@miky-rola miky-rola commented Mar 20, 2026

Summary

  • Containers leaked when _execute() hit a timeout or unexpected exception — only the normal exit path cleaned up
  • Moved _remove_container into a finally block so cleanup happens on all three exit paths
  • Captured elapsed before finally so elapsed_sec excludes cleanup overhead

Test plan

  • test_cleanup_on_normal_exit — removal called on success
  • test_cleanup_on_timeout — both kill and removal called
  • test_cleanup_on_exception — removal called on OSError
  • test_keep_containers_skips_removal — removal skipped when flag set

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.
@miky-rola miky-rola force-pushed the docker-container-leak branch from 2bf9c8a to 0ae7a81 Compare March 20, 2026 09:39
@Jiaaqiliu Jiaaqiliu merged commit d97f28e into aiming-lab:main Mar 22, 2026
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