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