From c262b1a3e813c941adcd515929e63d58678e077d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 18 Sep 2021 14:10:21 -0400 Subject: [PATCH] Always cancel the asyncio task? --- tractor/to_asyncio.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tractor/to_asyncio.py b/tractor/to_asyncio.py index c7bcc89..aa8c6fc 100644 --- a/tractor/to_asyncio.py +++ b/tractor/to_asyncio.py @@ -55,7 +55,8 @@ def _run_asyncio_task( or stream the result back to ``trio``. """ - assert current_actor().is_infected_aio() + if not current_actor().is_infected_aio(): + raise RuntimeError("`infect_asyncio` mode is not enabled!?") # ITC (inter task comms) from_trio = asyncio.Queue(qsize) # type: ignore @@ -174,11 +175,11 @@ async def run_task( else: raise - except trio.Cancelled: - if not task.done(): - task.cancel() - - raise + # except trio.Cancelled: + # raise + finally: + # if not task.done(): + task.cancel() # TODO: explicit api for the streaming case where