From 697c6152a6af4b57a7d1a1f66d981803229fe163 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 6 Jul 2026 11:40:39 -0400 Subject: [PATCH] Fix unbound `timeout` under non-trio/MTF backends `test_nested_multierrors`'s backend/depth budget `match` only carries arms for the `trio` + `main_thread_forkserver` spawn backends, so running under any other (e.g. `mp_spawn`) leaves `timeout` unbound and crashes with an `UnboundLocalError` at the headroom-scaling below. Add default per-depth arms riding the MTF budgets (same per-spawn round-trip cost class). (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tests/test_cancellation.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_cancellation.py b/tests/test_cancellation.py index aa61598b..34dbf90f 100644 --- a/tests/test_cancellation.py +++ b/tests/test_cancellation.py @@ -647,6 +647,14 @@ async def test_nested_multierrors( timeout = 16 case ('main_thread_forkserver', 3): timeout = 30 + # any other fork-based backend (`mp_spawn` et al) pays + # the same per-spawn round-trip costs as MTF so rides + # its budgets; without a default arm `timeout` is left + # unbound -> `UnboundLocalError` at the scaling below. + case (_, 1): + timeout = 16 + case (_, 3): + timeout = 30 # inflate the budget by the throttle headroom probed above so # a slow box doesn't masquerade as a deadline regression.