#121 has been running in "production" for some time and seems to work well.
In fact I'm pretty sure the debugger stuff just works, but it needs further scrutiny with some tests which will hopefully land in that PR.
We probably want to have an entirely separate section in the docs going over how to use the inter-loop API and how tractor can give you pseudo-SC on top of asyncio sub-actors where needed.
Some notes worth keeping in mind as this gets worked on:
- the functionality is as follows:
- ability to spawn an actor that has a process entry point of
asyncio.run()
- the asyncio actor embeds trio using the new guest mode which then enters the tractor.Actor._async_main() entry point thus engaging all the std IPC machinery
- the actor is now able to accept requests for async functions which can utilize the new tractor.to_asyncio.run() method which allows spawning tasks in the host asyncio loop and waiting/streaming the result(s) back into the trio task
results can then be relayed upwards to the parent actor as per normal operation
- notes on this implementation versus using
anyio:
- it ended up being possible to accomplish per task error propagation by simply doing a little state passing inside the callback passed to
asyncio.Task.add_done_callback() and thus not requiring the use of anyio
- I'm not even sure it's possible to do this with the task groups offered by
anyio due to the nature of spawning asyncio tasks from trio tasks and providing an api to acquire the results on demand.
- The main idea here is that a new tractor actor can be spawned and async functions that will run under
trio can make calls to spawn asyncio tasks using the new tractor.to_asyncio.run() routine which acts basically like tractor.Portal.run() but without any IPC stuff going on underneath
- All IPC is done as normal once results are back in the (embedded)
trio task.
Likely, we'll end up writing some simple examples that distill from the coming test set to get merged with #121.
#121 has been running in "production" for some time and seems to work well.
In fact I'm pretty sure the debugger stuff just works, but it needs further scrutiny with some tests which will hopefully land in that PR.
We probably want to have an entirely separate section in the docs going over how to use the inter-loop API and how
tractorcan give you pseudo-SC on top ofasynciosub-actors where needed.Some notes worth keeping in mind as this gets worked on:
asyncio.run()results can then be relayed upwards to the parent actor as per normal operation
anyio:asyncio.Task.add_done_callback()and thus not requiring the use ofanyioanyiodue to the nature of spawningasynciotasks fromtriotasks and providing an api to acquire the results on demand.triocan make calls to spawnasynciotasks using the newtractor.to_asyncio.run()routine which acts basically liketractor.Portal.run()but without any IPC stuff going on underneathtriotask.Likely, we'll end up writing some simple examples that distill from the coming test set to get merged with #121.