Repository navigation
fix(workspace): stop the container when cleanup runs on the logs thread - #6599
Merged
Merged
Conversation
DockerWorkspace.__del__ can run on the log-streaming thread when that thread drops the last reference, and cleanup() then tried to join the current thread, raising RuntimeError before `docker stop`, so the container kept running. Skip the join when cleanup is on that thread.
Closed
75 of 86 tasks
Contributor
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
VascoSch92
marked this pull request as ready for review
November 7, 2026 16:24
all-hands-bot
approved these changes
Nov 7, 2026
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.
HUMAN:
just fixing a bug
AGENT:
Why
DockerWorkspace.cleanup()stops log streaming and joins the logs thread before runningdocker stop. The logs thread holds a reference to the workspace, so when it is the one that drops the last reference,__del__runscleanup()on that thread.join()on the current thread raisesRuntimeError: cannot join current thread,docker stopnever runs, and the container is left running.Summary
cleanup()runs on a different thread. On the logs thread itself,_stop_logsis already set, so it exits on its own aftercleanup()returns.xfailmarker. It runscleanup()on the thread stored as_logs_threadand checks thatdocker stopis called and nothing raises.Issue Number
Part of #6348 (item: "cleanup() run on the log-streaming thread (as del does when that thread drops the last reference) raises 'cannot join current thread' before
docker stop").How to Test
test_cleanup_from_log_thread_still_stops_containerfails onmain(RuntimeError: cannot join current thread, nodocker stop) and passes here; the file passes (24).Type
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:642340c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
642340c-python) is a multi-arch manifest supporting both amd64 and arm64642340c-python-amd64) are also available if needed