Skip to content

fix(workspace): stop the container when cleanup runs on the logs thread - #6599

Merged
VascoSch92 merged 1 commit into
mainfrom
vasco/docker-cleanup-from-log-thread
Nov 7, 2026
Merged

VascoSch92 merged 1 commit into
mainfrom
vasco/docker-cleanup-from-log-thread

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

just fixing a bug


AGENT:

Why

DockerWorkspace.cleanup() stops log streaming and joins the logs thread before running docker stop. The logs thread holds a reference to the workspace, so when it is the one that drops the last reference, __del__ runs cleanup() on that thread. join() on the current thread raises RuntimeError: cannot join current thread, docker stop never runs, and the container is left running.

Summary

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

uv run pytest tests/workspace/test_docker_workspace.py

test_cleanup_from_log_thread_still_stops_container fails on main (RuntimeError: cannot join current thread, no docker stop) and passes here; the file passes (24).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

🐳 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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:642340c-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-642340c-python \
  ghcr.io/openhands/agent-server:642340c-python

All tags pushed for this build

ghcr.io/openhands/agent-server:642340c-golang-amd64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-golang-amd64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-golang-amd64
ghcr.io/openhands/agent-server:642340c-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:642340c-golang-arm64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-golang-arm64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-golang-arm64
ghcr.io/openhands/agent-server:642340c-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:642340c-java-amd64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-java-amd64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-java-amd64
ghcr.io/openhands/agent-server:642340c-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:642340c-java-arm64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-java-arm64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-java-arm64
ghcr.io/openhands/agent-server:642340c-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:642340c-python-amd64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-amd64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-amd64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-amd64
ghcr.io/openhands/agent-server:642340c-python-arm64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-arm64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-arm64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-arm64
ghcr.io/openhands/agent-server:642340c-python-minimal-amd64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-minimal-amd64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-minimal-amd64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:642340c-python-minimal-arm64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-minimal-arm64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-minimal-arm64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:642340c-python-slim-amd64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-slim-amd64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-slim-amd64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:642340c-python-slim-arm64
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-slim-arm64
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-slim-arm64
ghcr.io/openhands/agent-server:642340c-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:642340c-golang
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-golang
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-golang
ghcr.io/openhands/agent-server:642340c-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:642340c-java
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-java
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-java
ghcr.io/openhands/agent-server:642340c-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:642340c-python-minimal
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-minimal
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-minimal
ghcr.io/openhands/agent-server:642340c-python-node-runtime-minimal
ghcr.io/openhands/agent-server:642340c-python-slim
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python-slim
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python-slim
ghcr.io/openhands/agent-server:642340c-python-node-runtime-slim
ghcr.io/openhands/agent-server:642340c-python
ghcr.io/openhands/agent-server:642340cfdb2a5f6cea4914acce4d0624653cbe11-python
ghcr.io/openhands/agent-server:vasco-docker-cleanup-from-log-thread-python
ghcr.io/openhands/agent-server:642340c-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 642340c-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 642340c-python-amd64) are also available if needed

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.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-workspace/openhands/workspace/docker
   workspace.py1964577%30–32, 50, 148, 174, 198, 202, 209, 221–222, 234, 261, 298, 307, 314–315, 319–320, 324, 327–328, 330–336, 339–340, 349–351, 355–357, 361, 365, 371–372, 386, 400, 420, 437
TOTAL535672657950% 

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@VascoSch92
VascoSch92 marked this pull request as ready for review November 7, 2026 16:24
@VascoSch92
VascoSch92 merged commit 7a5011b into main Nov 7, 2026
52 of 53 checks passed
@VascoSch92
VascoSch92 deleted the vasco/docker-cleanup-from-log-thread branch November 7, 2026 17:17
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