Fix TUI slash worker zombie subprocess leak (#38095) - #38114
Closed
Elshayib wants to merge 2 commits into
Closed
Conversation
The main branch reported 0.15.1 / 2026.5.29 while the latest published release tag v2026.5.29.2 reports 0.15.2 / 2026.5.29.2. This caused source installs tracking origin/main to appear stale/downgraded. Update pyproject.toml, hermes_cli/__init__.py, and acp_registry/agent.json to match the release tag metadata. Fixes #38093
Three related fixes in tui_gateway/server.py: 1. _finalize_session() now closes the slash worker subprocess before returning. Previously, any code path that called _finalize_session() without separately handling the worker would leak the subprocess. 2. _SlashWorker.close() is more robust: increased terminate->wait timeout from 1s to 5s, added explicit stdout/stderr/stdin close to drain reader threads, and a final wait(2) to reap the zombie. The old 1s timeout was too short for slow machines under load. 3. _restart_slash_worker() now clears session[\"slash_worker\"] = None after closing the old worker, preventing a window where both old and new workers are simultaneously live (observed as duplicate session-key workers in the wild). Co-Authored-By: OWL <noreply@zoo-ai.com>
Contributor
|
Superseded by #42132 (merged), which closes the slash_worker subprocess leak via two guards: process-group kill on PTY teardown + a cross-platform parent-death watchdog in the worker. Closing as resolved — thanks for tackling this; the merged fix salvaged the process-group-kill and watchdog approaches with contributor authorship preserved. |
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
Fixes #38095 — TUI slash worker subprocesses leak after session close, accumulating zombie processes.
Three related fixes in tui_gateway/server.py:
_finalize_session() now closes the slash worker. Previously, any code path that called _finalize_session() without separately handling the worker would leak the subprocess. The session.close handler and _shutdown_sessions() had redundant separate close logic, but _finalize_session() itself did not.
_SlashWorker.close() is more robust. Increased terminate→wait timeout from 1s to 5s, added explicit stdout/stderr/stdin close to unblock reader threads, and a final wait(2) to reap the zombie. The old 1s timeout was too short for slow machines under load.
_restart_slash_worker() clears the old reference. Sets session["slash_worker"] = None after closing the old worker, preventing a window where both old and new workers are simultaneously live (observed as duplicate session-key workers in the wild).
Tests
Added 5 new tests in tests/test_tui_gateway_server.py:
All 5 tests pass.