fix(kanban): terminate worker process on block/archive/complete (#57596) - #57602
liuhao1024 wants to merge 2 commits into
Conversation
When a Kanban task transitions away from running via block_task, archive_task, or complete_task, the worker_pid is cleared in the database but the actual subprocess was never signaled — leaving orphaned workers consuming CPU until manually killed. Now calls _terminate_reclaimed_worker() (the same function used by reclaim_task and release_stale_claims) from all status-transition paths that clear worker_pid. Also fixes _set_status_direct (dashboard drag-drop) which had the same gap. Fixes NousResearch#57596
Duplicate of #31365 — same mechanism (calling |
|
Closing as superseded by #31365 — same mechanism (terminating live workers on manual The alt-glitch duplicate signal is correct here. |
What does this PR do?
Terminates the worker subprocess when a Kanban task transitions away from
runningviablock_task,archive_task, orcomplete_task. Previously these functions clearedworker_pidin the database but never sent a signal to the actual process, leaving orphaned workers consuming CPU until manually killed.The existing
_terminate_reclaimed_worker()function (used byreclaim_taskandrelease_stale_claims) is now also called from the status-transition paths.Related Issue
Fixes #57596
Type of Change
Changes Made
hermes_cli/kanban_db.py—block_task(): addedworker_pid, claim_lockto initial SELECT; calls_terminate_reclaimed_worker()at both return paths (dependency block and normal block)hermes_cli/kanban_db.py—archive_task(): readsworker_pid, claim_lockbefore the UPDATE; calls_terminate_reclaimed_worker()after the DB transitionhermes_cli/kanban_db.py—complete_task(): readsworker_pid, claim_lockbefore the UPDATE; calls_terminate_reclaimed_worker()after the DB transitionplugins/kanban/dashboard/plugin_api.py—_set_status_direct(): addedworker_pid, claim_lockto the SELECT; callskanban_db._terminate_reclaimed_worker()when transitioning from runningtests/hermes_cli/test_kanban_worker_termination.py— 7 new tests verifying termination is called for running→blocked/archived/done transitions and skipped when no PID is setHow to Test
pytest tests/hermes_cli/test_kanban_worker_termination.py -v— all 7 tests should passpytest tests/hermes_cli/test_kanban_block_kinds.py tests/hermes_cli/test_kanban_db.py tests/hermes_cli/test_kanban_core_functionality.py -q— all existing tests should pass (no regressions)runningstatus with a worker, then archive it from the dashboard — the worker process should be terminated (no orphan)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A_terminate_reclaimed_workerwhich is already cross-platform)