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

Open
opened 2026-11-26 20:20:54 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1305
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/tui-pump-process-timeout


📝 Commits (1)

  • 2be1e56 leonida_tui: terminate only the timed-out child in pump_process

📊 Changes

2 files changed (+130 additions, -23 deletions)

View changed files

📝 tests/test_leonida_tui.py (+102 -0)
📝 tools/leonida_tui.py (+28 -23)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1305 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/tui-pump-process-timeout` --- ### 📝 Commits (1) - [`2be1e56`](https://github.com/ubiquitarianism/leonida/commit/2be1e5647acf97839fa4c62eedcd0e5137e01fcc) leonida_tui: terminate only the timed-out child in pump_process ### 📊 Changes **2 files changed** (+130 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_leonida_tui.py` (+102 -0) 📝 `tools/leonida_tui.py` (+28 -23) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1335
No description provided.