Exercise active RPC tasks in SIGINT test
Open one linked sleeping context in each daemon and wait for every `StartAck` before `test_cancel_via_SIGINT_other_task()` reports startup. This restores the legacy test's active remote-task cancellation target instead of proving SIGINT teardown only against idle actor runtimes. Review: PR #484 (OpenCode) https://github.com/goodboy/tractor/pull/484#pullrequestreview-5025383596 (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))drop_ria_nursery
parent
1d59f1963c
commit
37eeb7bab6
|
|
@ -94,6 +94,18 @@ async def sleep_forever():
|
||||||
await trio.sleep_forever()
|
await trio.sleep_forever()
|
||||||
|
|
||||||
|
|
||||||
|
@tractor.context
|
||||||
|
async def sleep_forever_ctx(
|
||||||
|
ctx: tractor.Context,
|
||||||
|
) -> None:
|
||||||
|
'''
|
||||||
|
Signal task startup before sleeping until context cancellation.
|
||||||
|
|
||||||
|
'''
|
||||||
|
await ctx.started()
|
||||||
|
await sleep_forever()
|
||||||
|
|
||||||
|
|
||||||
async def do_nuthin():
|
async def do_nuthin():
|
||||||
# just nick the scheduler
|
# just nick the scheduler
|
||||||
await trio.sleep(0)
|
await trio.sleep(0)
|
||||||
|
|
@ -827,15 +839,25 @@ 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 an:
|
) as an:
|
||||||
# just keep a set of (daemon) subactors alive for the
|
portals = [
|
||||||
# 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):
|
|
||||||
await an.start_actor(
|
await an.start_actor(
|
||||||
f'namesucka_{i}',
|
f'namesucka_{i}',
|
||||||
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
task_status.started()
|
for i in range(3)
|
||||||
await trio.sleep_forever()
|
]
|
||||||
|
|
||||||
|
# Keep one linked RPC task active in every daemon before
|
||||||
|
# reporting startup, preserving the original
|
||||||
|
# `run_in_actor(sleep_forever)` cancellation target.
|
||||||
|
async with gather_contexts(
|
||||||
|
mngrs=[
|
||||||
|
portal.open_context(sleep_forever_ctx)
|
||||||
|
for portal in portals
|
||||||
|
],
|
||||||
|
):
|
||||||
|
task_status.started()
|
||||||
|
await trio.sleep_forever()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# should never timeout since SIGINT should cancel the current program
|
# should never timeout since SIGINT should cancel the current program
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue