Clear fatal-error interrupt window unconditionally on body exit

Merged
MA
2mo ago
+91-10

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

Follow-up to #6990 (merged while this review round was in flight), addressing the two review threads that were still open there:

  1. cubic's finding is valid: run_concurrently_context cleared in_body only on the normal post-body path and in the KeyboardInterrupt handler. If the with-body raises any other exception, in_body stays True — and since the executor shuts down with wait=False, a task failing after the context has unwound could still deliver a stray SIGINT into unrelated caller code. The fix wraps the yield in a try/finally that clears in_body however the body exits, replacing the two scattered clears — a net simplification of the mechanism, not an addition (per the review discussion, no extra guarded setup path).
  2. greptile's nit: the hang regression test's bare 5-second assertion threshold now carries a comment explaining its relationship to the body's 10s wait.

Adds test_run_concurrently_context_no_interrupt_after_body_exception, which pins the escaped-interrupt case (late-failing task + body exception → the body's own ValueError propagates, no stray KeyboardInterrupt).

Test Plan

  • uv run pytest tests/units/utils/test_processes.py -k run_concurrently: 4 passed (the new test plus the three from #6990).
  • uv run ruff check / ruff format --check clean on changed files; uv run pyright 0 errors on changed files.
  • reflex-release changelog-check --base-ref origin/main passes.
  • The two test_is_process_on_port_* failures in this sandbox are pre-existing on clean main here (container network stack), unrelated to the diff.

šŸ¤– Generated with Claude Code

https://claude.ai/code/session_01EMjBXPozsNeQNSBZecNH8x


Generated by Claude Code