Add anti-hang `fail_after` cap to aio-cancel test

Wrap `test_tractor_cancels_aio`'s `main()` in a
`trio.fail_after(9 * cpu_perf_headroom())` so a wedged remote
runtime can't hang the test forever. This is the blessed
anti-hang guard here bc `pytest-timeout`'s global cap is
intentionally off (it breaks `trio` under the fork backends,
per the `pyproject` NOTE).

The cap is generous + CPU-headroom-scaled bc it's an anti-hang
guard, not a perf assertion. Motivated by the
`._ria_nursery`-removal regression where a wedged ria-reaper
once hung this exact test indefinitely.

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
drop_ria_nursery
Gud Boi 2026-07-02 19:45:22 -04:00
parent e617b498ec
commit d1fb4a1a26
1 changed files with 21 additions and 12 deletions

View File

@ -207,18 +207,27 @@ def test_tractor_cancels_aio(
'''
async def main():
async with tractor.open_nursery(
debug_mode=debug_mode,
registry_addrs=[reg_addr],
) as an:
portal = await an.run_in_actor(
asyncio_actor,
target='aio_sleep_forever',
expect_err='trio.Cancelled',
infect_asyncio=True,
)
# cancel the entire remote runtime
await portal.cancel_actor()
# anti-hang wall-clock cap: a per-test `trio.fail_after`
# is the blessed guard here since `pytest-timeout`'s
# global cap is intentionally off (see the `pyproject`
# NOTE — it breaks trio under fork backends). Generous +
# CPU-headroom-scaled bc this is an anti-hang guard, not
# a perf assertion; a wedged ria-reaper once hung this
# test forever (the `._ria_nursery`-removal regression).
from .conftest import cpu_perf_headroom
with trio.fail_after(9 * cpu_perf_headroom()):
async with tractor.open_nursery(
debug_mode=debug_mode,
registry_addrs=[reg_addr],
) as an:
portal = await an.run_in_actor(
asyncio_actor,
target='aio_sleep_forever',
expect_err='trio.Cancelled',
infect_asyncio=True,
)
# cancel the entire remote runtime
await portal.cancel_actor()
trio.run(main)