diff --git a/examples/debugging/asyncio_bp.py b/examples/debugging/asyncio_bp.py index fc3b222a..348e990f 100644 --- a/examples/debugging/asyncio_bp.py +++ b/examples/debugging/asyncio_bp.py @@ -18,15 +18,14 @@ async def aio_sleep_forever(): async def bp_then_error( - to_trio: trio.MemorySendChannel, - from_trio: asyncio.Queue, + chan: to_asyncio.LinkedTaskChannel, raise_after_bp: bool = True, ) -> None: # sync with `trio`-side (caller) task - to_trio.send_nowait('start') + chan.started_nowait('start') # NOTE: what happens here inside the hook needs some refinement.. # => seems like it's still `.debug._set_trace()` but diff --git a/examples/infected_asyncio_echo_server.py b/examples/infected_asyncio_echo_server.py index 02508351..20914089 100644 --- a/examples/infected_asyncio_echo_server.py +++ b/examples/infected_asyncio_echo_server.py @@ -11,21 +11,17 @@ import tractor async def aio_echo_server( - to_trio: trio.MemorySendChannel, - from_trio: asyncio.Queue, - + chan: tractor.to_asyncio.LinkedTaskChannel, ) -> None: # a first message must be sent **from** this ``asyncio`` # task or the ``trio`` side will never unblock from # ``tractor.to_asyncio.open_channel_from():`` - to_trio.send_nowait('start') + chan.started_nowait('start') - # XXX: this uses an ``from_trio: asyncio.Queue`` currently but we - # should probably offer something better. while True: # echo the msg back - to_trio.send_nowait(await from_trio.get()) + chan.send_nowait(await chan.get()) await asyncio.sleep(0) diff --git a/tests/test_child_manages_service_nursery.py b/tests/test_child_manages_service_nursery.py index 6379afc6..0c42dd93 100644 --- a/tests/test_child_manages_service_nursery.py +++ b/tests/test_child_manages_service_nursery.py @@ -18,16 +18,15 @@ from tractor import RemoteActorError async def aio_streamer( - from_trio: asyncio.Queue, - to_trio: trio.abc.SendChannel, + chan: tractor.to_asyncio.LinkedTaskChannel, ) -> trio.abc.ReceiveChannel: # required first msg to sync caller - to_trio.send_nowait(None) + chan.started_nowait(None) from itertools import cycle for i in cycle(range(10)): - to_trio.send_nowait(i) + chan.send_nowait(i) await asyncio.sleep(0.01) diff --git a/tests/test_infected_asyncio.py b/tests/test_infected_asyncio.py index 51ca6115..2ba932b1 100644 --- a/tests/test_infected_asyncio.py +++ b/tests/test_infected_asyncio.py @@ -47,12 +47,11 @@ async def sleep_and_err( # just signature placeholders for compat with # ``to_asyncio.open_channel_from()`` - to_trio: trio.MemorySendChannel|None = None, - from_trio: asyncio.Queue|None = None, + chan: to_asyncio.LinkedTaskChannel|None = None, ): - if to_trio: - to_trio.send_nowait('start') + if chan: + chan.started_nowait('start') await asyncio.sleep(sleep_for) assert 0 @@ -399,7 +398,7 @@ async def no_to_trio_in_args(): async def push_from_aio_task( sequence: Iterable, - to_trio: trio.abc.SendChannel, + chan: to_asyncio.LinkedTaskChannel, expect_cancel: False, fail_early: bool, exit_early: bool, @@ -407,15 +406,12 @@ async def push_from_aio_task( ) -> None: try: - # print('trying breakpoint') - # breakpoint() - # sync caller ctx manager - to_trio.send_nowait(True) + chan.started_nowait(True) for i in sequence: print(f'asyncio sending {i}') - to_trio.send_nowait(i) + chan.send_nowait(i) await asyncio.sleep(0.001) if ( @@ -1109,13 +1105,12 @@ async def raise_before_started( ) -> None: ''' `asyncio.Task` entry point which RTEs before calling - `to_trio.send_nowait()`. + `chan.started_nowait()`. ''' await asyncio.sleep(0.2) raise RuntimeError('Some shite went wrong before `.send_nowait()`!!') - # to_trio.send_nowait('Uhh we shouldve RTE-d ^^ ??') chan.started_nowait('Uhh we shouldve RTE-d ^^ ??') await asyncio.sleep(float('inf')) diff --git a/tests/test_root_infect_asyncio.py b/tests/test_root_infect_asyncio.py index 78f9b2b4..159aa3d5 100644 --- a/tests/test_root_infect_asyncio.py +++ b/tests/test_root_infect_asyncio.py @@ -91,13 +91,12 @@ def test_infected_root_actor( async def sync_and_err( # just signature placeholders for compat with # ``to_asyncio.open_channel_from()`` - to_trio: trio.MemorySendChannel, - from_trio: asyncio.Queue, + chan: tractor.to_asyncio.LinkedTaskChannel, ev: asyncio.Event, ): - if to_trio: - to_trio.send_nowait('start') + if chan: + chan.started_nowait('start') await ev.wait() raise RuntimeError('asyncio-side')