Originally from the discussion in #287,
Yeah, after spelunking the original design a bit yesterday I think I'm of the opinion that we should at the least decouple .run_in_actor() from the nursery internals and at most possibly deprecate it from the nursery API.
Argument:
.run_in_actor() calls can be implemented using .start_actor() + a Portal.run() call spawned from a local trio nursery task
further, a Portal.run() call can be implemented using Portal.open_context() with special handling on child side in the RPC ._invoke() impl; it might actually already be done that way?
-> we can offer a "wrapper" high level API that provides .run_in_actor() as part of a small worker pool API?
I like adopting the parlance from other projects such as .to_thread, to_process, and think we should instead offer a tractor.to_actor. subpkg of APIs which deliver these "higher level one shot" style apis for doing single remote task invocation.
The benefits include:
-
massively simplifying our actor nursery cancellation/spawn machinery
-
moving error collection and propagation up to some local trio task nursery which is not the same nursery responsible for creating subproc management / spawn tasks
yes! this allows us to drop the iface from ActorNursery (and/or possibly Portal? though not sure on this yet) as needed - which would reduce surface area and the current complexity of .run_in_actor() being couple to multiple runtime layers.
- a simpler API where we can demonstrate how to build the higher level constructs like a worker pool from primitives and there is less ways to do the same thing.
Also linking #172 as maybe another tidbit to consider as sugar level API.
Also see nods in the doc regarding this,
https://goodboy.github.io/tractor/api/core.html#tractor.ActorNursery.run_in_actor
and the original deprecation PR,
#290
Originally from the discussion in #287,
.run_in_actor()remote task #287 (comment).run_in_actor()remote task #287 (comment).run_in_actor()remote task #287 (comment)further, a
Portal.run()call can be implemented usingPortal.open_context()with special handling on child side in the RPC._invoke()impl; it might actually already be done that way?I like adopting the parlance from other projects such as
.to_thread,to_process, and think we should instead offer atractor.to_actor. subpkg of APIs which deliver these "higher level one shot" style apis for doing single remote task invocation.yes! this allows us to drop the iface from
ActorNursery(and/or possiblyPortal? though not sure on this yet) as needed - which would reduce surface area and the current complexity of.run_in_actor()being couple to multiple runtime layers.Also see nods in the doc regarding this,
https://goodboy.github.io/tractor/api/core.html#tractor.ActorNursery.run_in_actor
and the original deprecation PR,
#290