goodboy / tractor

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

Supervisor API #22

Open goodboy opened 6 years ago

goodboy commented 6 years ago

I want to start design discussion on how to approach erlang-like supervisors including restart strategies and how this will interplay with a service discovery system and possibly real-time code replacement.

Some questions/comments I have:

Much more to come...

goodboy commented 3 years ago

Worth a read is elixir's page on supervisors and dynamic supervisors.

goodboy commented 3 years ago

We had a brief discussion a while back slightly in regard to #190 (this comment) related apis.

For supervisors I actually think we can make quite a nice api by just offering composed async context managers:

async with tractor.open_nursery() as n:

    async with tractor.supervise.one_for_one(n) as one_for_one_nursery:

        await one_for_one_nursery.run_in_actor(blah)

In 3.10 parentheses syntax this becomes:

async with (
    tractor.open_nursery() as n,
    tractor.supervise.one_for_one(n) as one_for_one_nursery,
):        
        await one_for_one_nursery.run_in_actor(blah)

This has the benefit of being simple to implement:

Further questions:

goodboy commented 3 years ago

tenacity is an interesting project that seems to be defacto for python restarts.

I think the most compatible (though not fully convinced yet) api that we might want to adopt is the code block retrying.

njs just proposed better native trio support as well.

goodboy commented 3 years ago

A nice short post from @catern affirming the supervisor at every layer design is the future of process management.