Port SIGINT + sync-sleep cancel tests off `run_in_actor`
Final `test_cancellation.py` group of the `run_in_actor` removal (#477) — cancel-mechanics tests, so clean conversions, - `test_cancel_via_SIGINT_other_task`: the 3 keep-alive `run_in_actor(sleep_forever)` one-shots become plain `start_actor()` daemons (an idle daemon needs no "main" task, and no longer shares a single dup'd `namesucka` name). - `spawn_sub_with_sync_blocking_task`: the middle layer's spawn becomes a blocking `to_actor.run(spin_for, an=an)` which parks awaiting the sync-sleeping grandchild's result until cancelled from above. - `test_cancel_while_childs_child_in_sync_sleep`: the fire-and-forget middle-actor spawn becomes a bg `to_actor.run()` task in a local task-nursery; the root's `assert 0` cancels it, driving the same graceful-cancel-then-zombie-reap cascade on the sync-blocked grandchild. The `man_cancel_outer` xfail param is unchanged. Zero live `run_in_actor()` call-sites remain in this suite. Gate: full `test_cancellation.py` module green on both `trio` (18p/1xf) + `mp_spawn` (18p/1xf). (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
fa8799d5bb
commit
f11754cecf
|
|
@ -837,11 +837,13 @@ def test_cancel_via_SIGINT_other_task(
|
||||||
):
|
):
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
registry_addrs=[reg_addr],
|
registry_addrs=[reg_addr],
|
||||||
) as tn:
|
) as an:
|
||||||
|
# just keep a set of (daemon) subactors alive for the
|
||||||
|
# SIGINT to cancel (was 3 `run_in_actor(sleep_forever)`
|
||||||
|
# one-shots — a daemon needs no "main" task to idle).
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
await tn.run_in_actor(
|
await an.start_actor(
|
||||||
sleep_forever,
|
f'namesucka_{i}',
|
||||||
name='namesucka',
|
|
||||||
)
|
)
|
||||||
task_status.started()
|
task_status.started()
|
||||||
await trio.sleep_forever()
|
await trio.sleep_forever()
|
||||||
|
|
@ -882,8 +884,11 @@ async def spin_for(period=3):
|
||||||
async def spawn_sub_with_sync_blocking_task():
|
async def spawn_sub_with_sync_blocking_task():
|
||||||
async with tractor.open_nursery() as an:
|
async with tractor.open_nursery() as an:
|
||||||
print('starting sync blocking subactor..\n')
|
print('starting sync blocking subactor..\n')
|
||||||
await an.run_in_actor(
|
# one-shot: parks HERE awaiting the sync-sleeping
|
||||||
|
# grandchild's result until cancelled from above.
|
||||||
|
await tractor.to_actor.run(
|
||||||
spin_for,
|
spin_for,
|
||||||
|
an=an,
|
||||||
name='sleeper',
|
name='sleeper',
|
||||||
)
|
)
|
||||||
print('exiting first subactor layer..\n')
|
print('exiting first subactor layer..\n')
|
||||||
|
|
@ -989,11 +994,19 @@ def test_cancel_while_childs_child_in_sync_sleep(
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
registry_addrs=[reg_addr],
|
registry_addrs=[reg_addr],
|
||||||
) as an,
|
) as an,
|
||||||
|
trio.open_nursery() as tn,
|
||||||
):
|
):
|
||||||
await an.run_in_actor(
|
# bg one-shot: parks on the middle actor's result
|
||||||
|
# (itself parked on the sync-sleeping grandchild)
|
||||||
|
# until the `assert 0` below cancels this scope.
|
||||||
|
tn.start_soon(
|
||||||
|
partial(
|
||||||
|
tractor.to_actor.run,
|
||||||
spawn_sub_with_sync_blocking_task,
|
spawn_sub_with_sync_blocking_task,
|
||||||
|
an=an,
|
||||||
name='sync_blocking_sub',
|
name='sync_blocking_sub',
|
||||||
)
|
)
|
||||||
|
)
|
||||||
await trio.sleep(1)
|
await trio.sleep(1)
|
||||||
|
|
||||||
if man_cancel_outer:
|
if man_cancel_outer:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue