leonida_tui: terminate only the timed-out child in pump_process (TUI-PUMP-PROCESS-TIMEOUT) #1305

Open
github-bot wants to merge 1 commit from github-bot/gh-1305 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 21:37 UTC · original
ambroseautomation:fix/tui-pump-process-timeout → main · +130 −23 · 2 files · 1 commits · open

Summary

Coordination item: TUI-PUMP-PROCESS-TIMEOUT (reported by @jtoucas-DIMO in #14).

Problem & Root Cause

In tools/leonida_tui.py, pump_process() waits up to 0.5s for proc to exit after its stdout reaches EOF. On subprocess.TimeoutExpired, it called kill_live_processes(), which iterates over the global _live_procs set and kills every monitored subprocess (and clears _live_procs), terminating unrelated parallel workers (such as concurrent shader shards or overlapped build stages) whenever one child lingers after closing stdout.

Implementation

  • Extracted _terminate_process(proc) from kill_live_processes() in tools/leonida_tui.py (preserving Windows taskkill /F /T /PID tree termination and POSIX terminate() → wait(1.0) → kill() fallback).
  • Updated pump_process() to call _terminate_process(proc) on post-EOF subprocess.TimeoutExpired instead of kill_live_processes(), so only the timed-out child is terminated and later unregistered in finally, while sibling live processes remain running and registered.
  • Added PumpProcessTimeoutTest in tests/test_leonida_tui.py covering both POSIX (terminate()) and Windows (taskkill /F /T /PID) paths with a registered sibling process.

Tests Run

Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic FakeProc fixtures only (no game data).

  • python -I -m py_compile tools/leonida_tui.py tests/test_leonida_tui.py — PASS
  • python -I tests/test_leonida_tui.py -v — 27/27 PASS (including 2 new tests in PumpProcessTimeoutTest)
  • pytest tests/test_leonida_tui.py tests/test_text_write_line_endings.py -v — 30/30 PASS
  • python -I scripts/check_no_game_data.py tools/leonida_tui.py tests/test_leonida_tui.py — PASS

Disclosure

AI-assisted: yes

**@⁠ambroseautomation** on GitHub · 2026-11-24 21:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1305) `ambroseautomation:fix/tui-pump-process-timeout` → `main` · +130 −23 · 2 files · 1 commits · open ## Summary Coordination item: `TUI-PUMP-PROCESS-TIMEOUT` (reported by `@jtoucas-DIMO` in #14). ### Problem & Root Cause In `tools/leonida_tui.py`, `pump_process()` waits up to `0.5s` for `proc` to exit after its `stdout` reaches EOF. On `subprocess.TimeoutExpired`, it called `kill_live_processes()`, which iterates over the global `_live_procs` set and kills **every** monitored subprocess (and clears `_live_procs`), terminating unrelated parallel workers (such as concurrent shader shards or overlapped build stages) whenever one child lingers after closing stdout. ### Implementation - Extracted `_terminate_process(proc)` from `kill_live_processes()` in `tools/leonida_tui.py` (preserving Windows `taskkill /F /T /PID` tree termination and POSIX `terminate()` → `wait(1.0)` → `kill()` fallback). - Updated `pump_process()` to call `_terminate_process(proc)` on post-EOF `subprocess.TimeoutExpired` instead of `kill_live_processes()`, so only the timed-out child is terminated and later unregistered in `finally`, while sibling live processes remain running and registered. - Added `PumpProcessTimeoutTest` in `tests/test_leonida_tui.py` covering both POSIX (`terminate()`) and Windows (`taskkill /F /T /PID`) paths with a registered sibling process. ## Tests Run Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic `FakeProc` fixtures only (no game data). - `python -I -m py_compile tools/leonida_tui.py tests/test_leonida_tui.py` — PASS - `python -I tests/test_leonida_tui.py -v` — 27/27 PASS (including 2 new tests in `PumpProcessTimeoutTest`) - `pytest tests/test_leonida_tui.py tests/test_text_write_line_endings.py -v` — 30/30 PASS - `python -I scripts/check_no_game_data.py tools/leonida_tui.py tests/test_leonida_tui.py` — PASS ## Disclosure AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:46:43 +00:00
Author
Owner

@⁠nicoco23 on GitHub · 2026-11-24 22:07 UTC · original · approved these changes

Reviewed the diff and ran the tests: python -I tests/test_leonida_tui.py -v on Windows 11, Python 3.12, 27 tests, OK.

The fix is the right scope: on the post-EOF TimeoutExpired, pump_process() now terminates only that child instead of calling kill_live_processes(), which killed every registered process.

Nits, none blocking:

  • In PumpProcessTimeoutTest, assertNotIn(hung, leonida_tui._live_procs) passes trivially if hung was never registered, so it does not show that the timed-out process is unregistered afterwards. Registering it first, then asserting after pump_process returns, would make it meaningful.
  • On Windows the taskkill return code is ignored and there is no proc.kill() fallback if taskkill fails.
  • On POSIX, terminate() only reaches the direct child, not its children. That was already the case before this change.

NOT AI-assisted review

**@⁠nicoco23** on GitHub · 2026-11-24 22:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1305#pullrequestreview-6048169152) · **approved these changes** Reviewed the diff and ran the tests: `python -I tests/test_leonida_tui.py -v` on Windows 11, Python 3.12, 27 tests, OK. The fix is the right scope: on the post-EOF TimeoutExpired, pump_process() now terminates only that child instead of calling kill_live_processes(), which killed every registered process. Nits, none blocking: - In PumpProcessTimeoutTest, assertNotIn(hung, leonida_tui._live_procs) passes trivially if `hung` was never registered, so it does not show that the timed-out process is unregistered afterwards. Registering it first, then asserting after pump_process returns, would make it meaningful. - On Windows the taskkill return code is ignored and there is no proc.kill() fallback if taskkill fails. - On POSIX, terminate() only reaches the direct child, not its children. That was already the case before this change. NOT AI-assisted review
This pull request has changes conflicting with the target branch.
  • tests/test_leonida_tui.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1305/head:github-bot/gh-1305'
git switch 'github-bot/gh-1305'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1305'
git switch 'github-bot/gh-1305'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1305'
git switch 'github-bot/gh-1305'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1305'
git switch 'main'
git merge --squash 'github-bot/gh-1305'
git switch 'main'
git merge --ff-only 'github-bot/gh-1305'
git switch 'main'
git merge 'github-bot/gh-1305'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.