From 9b14d82086095283ea7f02687bff935d85ccce80 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 12 Dec 2021 16:33:48 -0500 Subject: [PATCH] Add nooz --- newsfragments/121.feature.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 newsfragments/121.feature.rst diff --git a/newsfragments/121.feature.rst b/newsfragments/121.feature.rst new file mode 100644 index 0000000..2ba8fc0 --- /dev/null +++ b/newsfragments/121.feature.rst @@ -0,0 +1,28 @@ +Add "infected ``asyncio`` mode; a sub-system to spawn and control +``asyncio`` actors using ``trio``'s guest-mode. + +This gets us the following very interesting functionality: + +- ability to spawn an actor that has a process entry point of + ``asyncio.run()`` by passing ``infect_asyncio=True`` to + ``Portal.start_actor()`` (and friends). +- the ``asyncio`` actor embeds ``trio`` using guest-mode and starts + a main ``trio`` task which runs the ``tractor.Actor._async_main()`` + entry point engages all the normal ``tractor`` runtime IPC/messaging + machinery; for all purposes the actor is now running normally on + a ``trio.run()``. +- the actor can now make one-to-one task spawning requests to the + underlying ``asyncio`` event loop using either of: + * ``to_asyncio.run_task()`` to spawn and run an ``asyncio`` task to + completion and block until a return value is delivered. + * ``async with to_asyncio.open_channel_from():`` which spawns a task + and hands it a pair of "memory channels" to allow for bi-directional + streaming between the now SC-linked ``trio`` and ``asyncio`` tasks. + +The output from any call(s) to ``asyncio`` can be handled as normal in +``trio``/``tractor`` task operation with the caveat of the overhead due +to guest-mode use. + +For more details see the `original PR +`_ and `issue +`_.