From 0fafd25f0d8b1fdd92b2f79aaea69e92feedfbb0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 19 Aug 2025 12:33:47 -0400 Subject: [PATCH] Comment tweaks per copilot review --- tractor/to_asyncio.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tractor/to_asyncio.py b/tractor/to_asyncio.py index 9c7b12b4..bd46a5ab 100644 --- a/tractor/to_asyncio.py +++ b/tractor/to_asyncio.py @@ -215,7 +215,7 @@ class LinkedTaskChannel( val: Any = None, ) -> None: ''' - Synchronize aio-sde with its trio-parent. + Synchronize aio-side with its trio-parent. ''' self._aio_started_val = val @@ -459,14 +459,22 @@ def _run_asyncio_task( f'Task exited with final result: {result!r}\n' ) - # only close the aio (child) side which will relay - # a `trio.EndOfChannel` to the trio (parent) side. + # XXX ALWAYS close the child-`asyncio`-task-side's + # `to_trio` handle which will in turn relay + # a `trio.EndOfChannel` to the `trio`-parent. + # Consequently the parent `trio` task MUST ALWAYS + # check for any `chan._aio_err` to be raised when it + # receives an EoC. + # + # NOTE, there are 2 EoC cases, + # - normal/graceful EoC due to the aio-side actually + # terminating its "streaming", but the task did not + # error and is not yet complete. + # + # - the aio-task terminated and we specially mark the + # closure as due to the `asyncio.Task`'s exit. # - # XXX NOTE, that trio-side MUST then in such cases - # check for a `chan._aio_err` and raise it!! to_trio.close() - # specially mark the closure as due to the - # asyncio.Task terminating! chan._closed_by_aio_task = True aio_task_complete.set() @@ -846,8 +854,6 @@ async def translate_aio_errors( chan._trio_to_raise = aio_err trio_err = chan._trio_err = eoc # - # await tractor.pause(shield=True) - # # ?TODO?, raise something like a, # chan._trio_to_raise = AsyncioErrored() # BUT, with the tb rewritten to reflect the underlying