From 359bcf691fd90a76968112a410d480e2f34a8652 Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 13 Mar 2026 20:54:49 -0400 Subject: [PATCH] Update `docs/README.rst` to use `chan` API style Sync the inline "infected asyncio" echo-server example with the new `LinkedTaskChannel` iface from prior commits. - `to_trio`/`from_trio` params -> `chan: LinkedTaskChannel` - use `chan.started_nowait()`, `.send_nowait()`, `.get()` - swap yield order to `(chan, first)` - update blurb to describe the new unified channel API (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- docs/README.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/README.rst b/docs/README.rst index 1d8bbb9f..f68ebd9a 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -420,20 +420,17 @@ Check out our experimental system for `guest`_-mode controlled 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) @@ -445,7 +442,7 @@ Check out our experimental system for `guest`_-mode controlled # 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) @@ -504,8 +501,10 @@ Yes, we spawn a python process, run ``asyncio``, start ``trio`` on the ``asyncio`` loop, then send commands to the ``trio`` scheduled tasks to tell ``asyncio`` tasks what to do XD -We need help refining the `asyncio`-side channel API to be more -`trio`-like. Feel free to sling your opinion in `#273`_! +The ``asyncio``-side task receives a single +``chan: LinkedTaskChannel`` handle providing a ``trio``-like +API: ``.started_nowait()``, ``.send_nowait()``, ``.get()`` +and more. Feel free to sling your opinion in `#273`_! .. _#273: https://github.com/goodboy/tractor/issues/273