forked from goodboy/tractor
1
0
Fork 0

Add a cancelled-from-remote-trio-task case

infect_asyncio
Tyler Goodlet 2021-11-18 14:01:13 -05:00
parent c19123b588
commit e815f766f6
1 changed files with 25 additions and 0 deletions

View File

@ -22,6 +22,31 @@ async def sleep_forever():
await asyncio.sleep(float('inf')) await asyncio.sleep(float('inf'))
async def trio_cancels_single_aio_task():
# spawn an ``asyncio`` task to run a func and return result
with trio.move_on_after(.2):
await tractor.to_asyncio.run_task(sleep_forever)
def test_trio_cancels_aio_on_actor_side(arb_addr):
'''
Spawn an infected actor that is cancelled by the ``trio`` side
task using std cancel scope apis.
'''
async def main():
async with tractor.open_nursery(
arbiter_addr=arb_addr
) as n:
await n.run_in_actor(
trio_cancels_single_aio_task,
infect_asyncio=True,
)
trio.run(main)
async def asyncio_actor( async def asyncio_actor(
target: str, target: str,