From 46963c2e6351ad9ccef77186df4abed676d3ab94 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 7 Mar 2022 16:25:48 -0500 Subject: [PATCH] Don't handle `GeneratorExit` on `asyncio` tasks --- tractor/to_asyncio.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tractor/to_asyncio.py b/tractor/to_asyncio.py index 371a936..ca15b00 100644 --- a/tractor/to_asyncio.py +++ b/tractor/to_asyncio.py @@ -109,6 +109,7 @@ def _run_asyncio_task( or stream the result back to ``trio``. ''' + __tracebackhide__ = True if not current_actor().is_infected_aio(): raise RuntimeError("`infect_asyncio` mode is not enabled!?") @@ -167,6 +168,9 @@ def _run_asyncio_task( orig = result = id(coro) try: result = await coro + except GeneratorExit: + # no need to relay error + raise except BaseException as aio_err: chan._aio_err = aio_err raise @@ -295,7 +299,7 @@ async def translate_aio_errors( ): # relay cancel through to called ``asyncio`` task chan._aio_task.cancel( - msg=f'the `trio` caller task was cancelled:\n{trio_task.name}' + msg=f'the `trio` caller task was cancelled: {trio_task.name}' ) raise