fix(cli): flag the quiet -Q linger as consumed only after the loop runs

_quiet_notify_linger_done was set BEFORE continue_quiet_notify_completions,
so an exception between the flag and the loop's first wait made the finalize
pass skip a linger that never ran (children SIGPIPE — the #90879 class).
The flag now lands in a finally around the loop call: once the loop's first
wait has started, budget is consumed and the finalize re-wait is correctly
skipped; before that, an exception still lets finalize linger.
This commit is contained in:
kshitijk4poor
2026-09-14 20:30:31 +05:30
committed by kshitij
parent 1f3407aa00
commit 66fa63820d

19
cli.py
View File

@@ -4121,13 +4121,18 @@ def _run_quiet_single_query(cli, effective_query):
# One shared linger budget for the whole run: the loop below and the later
# _wait_for_oneshot_background_completions pass must not each wait the full
# oneshot_completion_wait_seconds on the same stuck notify_on_complete child.
cli._quiet_notify_linger_done = True
continued = continue_quiet_notify_completions(
getattr(cli, "session_id", "") or "",
_follow_up,
owns_event=getattr(cli, "_owns_process_notification", None),
linger_budget=quiet_notify_linger_seconds(),
)
# Flagged after the loop (finally-equivalent): the wait is the loop's first
# statement, so anything raising past that point has consumed budget the
# finalize pass must not re-wait.
try:
continued = continue_quiet_notify_completions(
getattr(cli, "session_id", "") or "",
_follow_up,
owns_event=getattr(cli, "_owns_process_notification", None),
linger_budget=quiet_notify_linger_seconds(),
)
finally:
cli._quiet_notify_linger_done = True
if isinstance(continued, dict):
result = continued
response = result.get("final_response", "") if isinstance(result, dict) else str(result)