Repository navigation
Conversation
…aper The atexit handler added in testcontainers#1017 called Reaper.delete_instance(), which force-removes the Ryuk container. Ryuk then never reached its reconnection timeout, so the containers of a session that exits normally were never reaped. At exit only the socket is closed now; delete_instance() stays for explicit use. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Mikhail Solomenik <56078241+pantafive@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #1140
The
atexithandler added in #1017 runsReaper.delete_instance(), which force-removes the Ryuk container while the interpreter shuts down. Ryuk reaps a session onlyRYUK_RECONNECTION_TIMEOUTafter its connection drops, so a process that exits normally leaves every container of its session running.The handler now closes only the socket. That still prevents the
ResourceWarningfrom #1017, and Ryuk reaps the session after the timeout.delete_instance()keeps its behaviour for explicit callers and reuses the newclose_socket().test_reaper_removes_session_containers_after_interpreter_exitstarts a container in a child interpreter withRYUK_RECONNECTION_TIMEOUT=1s, lets it exit normally and waits up to 30s for the container to disappear. It carries the sameskipif(is_mac())andinside_docker_checkmarks astest_wait_for_reaper.Testing, on Colima (Linux VM) with the macOS skip lifted locally:
TimeoutError: Container 661e2b17… was not removed within 30s (status=exited)tests/core/test_ryuk.pypassesResourceWarningat exit underpython -X devpre-commit run --fileson the changed files passes, mypy included