-
fix(cli): terminate streaming investigation cleanly on Ctrl+C (#1901)
发布于
2026-05-12 20:01:40 +00:00 - fix(cli): terminate streaming investigation cleanly on Ctrl+C
- stream_investigation_cli: poll queue with timeout, cancel async task on
KeyboardInterrupt, join background thread so Ctrl+C actually terminates. - run_investigation_cli_streaming: close generator on KeyboardInterrupt to
force background cleanup. - investigate_command: catch KeyboardInterrupt and exit with code 0.
- render_stream: skip _print_report() on interrupt so incomplete RCA panel
is not shown after user aborts. - Add tests for all four behaviours.
- fix(cli): type stream generator for mypy Generator.close()
-
Annotate stream_investigation_cli as Generator[StreamEvent] so KeyboardInterrupt cleanup via events.close() type-checks
-
Satisfy ruff UP043 using defaulted Generator form
- fix(cli): cancel streaming pump on GeneratorExit and drop KI sentinel
-
Call _cancel_pump() from stream_investigation_cli finally so .close() tears down without full join timeout
-
Replace KeyboardInterrupt queue sentinel with _InvestigationPumpCancelled; map to OpenSREError via _reraise
-
Mirror finally _cancel_pump in session _events()
-
Assert generator_close completes in under 2s wall time
- fix(cli): bound pump thread join and harden cancel scheduling
- Use thread.join(timeout=5) before re-raising queued BaseException in
stream_investigation_cli and session _events (matches finally guard). - Wrap call_soon_threadsafe(task.cancel) in suppress(RuntimeError) when the
event loop closes between is_closed() and scheduling (TOCTOU on Ctrl+C).
下载附件