diff --git a/examples/debugging/asyncio_bp.py b/examples/debugging/asyncio_bp.py index 348e990f..3e3247bb 100644 --- a/examples/debugging/asyncio_bp.py +++ b/examples/debugging/asyncio_bp.py @@ -59,7 +59,7 @@ async def trio_ctx( to_asyncio.open_channel_from( bp_then_error, # raise_after_bp=not bp_before_started, - ) as (first, chan), + ) as (chan, first), trio.open_nursery() as tn, ): diff --git a/examples/infected_asyncio_echo_server.py b/examples/infected_asyncio_echo_server.py index 20914089..e8d29dc3 100644 --- a/examples/infected_asyncio_echo_server.py +++ b/examples/infected_asyncio_echo_server.py @@ -33,7 +33,7 @@ async def trio_to_aio_echo_server( # message. async with tractor.to_asyncio.open_channel_from( aio_echo_server, - ) as (first, chan): + ) as (chan, first): assert first == 'start' await ctx.started(first) diff --git a/tests/test_child_manages_service_nursery.py b/tests/test_child_manages_service_nursery.py index 0c42dd93..820d9ca0 100644 --- a/tests/test_child_manages_service_nursery.py +++ b/tests/test_child_manages_service_nursery.py @@ -68,7 +68,7 @@ async def wrapper_mngr( else: async with tractor.to_asyncio.open_channel_from( aio_streamer, - ) as (first, from_aio): + ) as (from_aio, first): assert not first # cache it so next task uses broadcast receiver diff --git a/tests/test_infected_asyncio.py b/tests/test_infected_asyncio.py index 2ba932b1..7b1e952c 100644 --- a/tests/test_infected_asyncio.py +++ b/tests/test_infected_asyncio.py @@ -237,7 +237,7 @@ async def trio_ctx( trio.open_nursery() as tn, tractor.to_asyncio.open_channel_from( sleep_and_err, - ) as (first, chan), + ) as (chan, first), ): assert first == 'start' @@ -474,7 +474,7 @@ async def stream_from_aio( trio_exit_early )) - ) as (first, chan): + ) as (chan, first): assert first is True @@ -768,8 +768,8 @@ async def trio_to_aio_echo_server( async with to_asyncio.open_channel_from( aio_echo_server, ) as ( - first, # value from `chan.started_nowait()` above chan, + first, # value from `chan.started_nowait()` above ): assert first == 'start' diff --git a/tests/test_root_infect_asyncio.py b/tests/test_root_infect_asyncio.py index 159aa3d5..e7a307bc 100644 --- a/tests/test_root_infect_asyncio.py +++ b/tests/test_root_infect_asyncio.py @@ -49,7 +49,7 @@ def test_infected_root_actor( ), to_asyncio.open_channel_from( aio_echo_server, - ) as (first, chan), + ) as (chan, first), ): assert first == 'start' @@ -173,7 +173,7 @@ def test_trio_prestarted_task_bubbles( sync_and_err, ev=aio_ev, ) - ) as (first, chan), + ) as (chan, first), ): for i in range(5): diff --git a/tractor/to_asyncio.py b/tractor/to_asyncio.py index 3769bdd0..0da47475 100644 --- a/tractor/to_asyncio.py +++ b/tractor/to_asyncio.py @@ -1299,15 +1299,15 @@ async def open_channel_from( **target_kwargs, ) -> AsyncIterator[ - tuple[Any, LinkedTaskChannel] + tuple[LinkedTaskChannel, Any] ]: ''' Start an `asyncio.Task` as `target()` and open an inter-loop (linked) channel for streaming between it and the current `trio.Task`. - A pair `(Any, chan: LinkedTaskChannel)` is delivered - to the caller where the 1st element is the value + A pair `(chan: LinkedTaskChannel, Any)` is delivered + to the caller where the 2nd element is the value provided by the `asyncio.Task`'s unblocking call to `chan.started_nowait()`. @@ -1333,8 +1333,7 @@ async def open_channel_from( first = await chan.receive() # deliver stream handle upward - yield first, chan - # ^TODO! swap these!! + yield chan, first except trio.Cancelled as taskc: if cs.cancel_called: if isinstance(chan._trio_to_raise, AsyncioCancelled):