Open goodboy opened 6 years ago
Worth a read is elixir
's page on supervisors and dynamic supervisors.
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:
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.
A nice short post from @catern affirming the supervisor at every layer design is the future of process management.
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:
what's the (semantic) difference between a
nursery
and asupervisor
?supervisor
be specific to managing (possibly distributed) processes in which case does having anursery
mean anything other then a special type of supervisor?asyncio
might be approaching nurseries/supervisorsan explicit distinction should be made between a
MainProcess
supervisor and thearbiter
actorArbiter
is per-host and is part of service discovery between hostshow do we best implement a distributed supervisor (one that spawns actors over multiple hosts)?
arbiter
who will then create or use a host-local nursery?what does a distributed process supervisor API look like?
arbiter
and service discovery system?how does an orchestration layer build on all this?
here's erlang's supervisor behaviors
Much more to come...