fix: resolve rebase conflict in _teardown_session worker cleanup

Main folded slash_worker.close() into _finalize_session (the single
_finalized-guarded chokepoint) while #42143 was open. The rebase
conflicted with the PR's worker-close in _teardown_session. Keep both —
they target the same #38095 leak and _SlashWorker.close() is
idempotent (_closed/poll()-guarded) — so callers reaching
_teardown_session without the real _finalize_session (and the PR's own
tests, which monkeypatch _finalize_session out) still reap the worker.
Same for _shutdown_sessions, now routed through the unified
_close_session_by_id funnel.
This commit is contained in:
teknium1 2026-06-08 09:42:48 -07:00
parent ae94ed1728
commit 365813a72b
No known key found for this signature in database
3 changed files with 37 additions and 12 deletions

View file

@ -425,10 +425,10 @@ def _teardown_session(session: dict | None, *, end_reason: str = "tui_close") ->
agent.close()
except Exception:
pass
# NOTE: the slash-worker subprocess is already closed inside
# _finalize_session (the single _finalized-guarded chokepoint on main).
# No second worker.close() here — it would be redundant (poll()-guarded,
# harmless, but dead).
# NOTE: the slash-worker is closed inside _finalize_session (the single
# _finalized-guarded chokepoint that main folded it into), exactly once.
# We deliberately do NOT re-close it here — _teardown_session's job beyond
# finalize is unregistering the notifier and closing the in-process agent.
def _attach_worker(sid: str, session: dict, worker) -> None: