goodboy / tractor

A distributed, structured concurrent runtime for Python (and friends)
GNU Affero General Public License v3.0
271 stars 12 forks source link

An actor-runtime equivalent of `trio`'s "guest mode" #359

Open goodboy opened 1 year ago

goodboy commented 1 year ago

This is an idea that just popped up randomly when looking through some ray examples / discussion, particularly this trio issue comment: https://github.com/python-trio/trio/issues/2135#issuecomment-934109228

import ray

ray.init()

@ray.remote
def task():

    import trio  # key part, importing in remote thread!

    async def sleeper():
        await trio.sleep(1)

    trio.run(sleeper)

task.remote()

Wait wut's the idea?

Can we support an embeddable API for launching the tractor runtime inside any thread/process spawning system which can run trio?

The short answer is intuitively yes to me, but i'm sure there's quite a bit that might have to go into it.


Motivations:


High level API design

Obviously a lot more to go into in this section ..