I've rambled on wayyy too long in #287 but thanks to attempts to
resolve that issue I think this is the way I'd like to go on a so
called one shot task per actor-style "worker pool" API.
Proposed re-factored "one-shot" style API
After (too) much thought about where/how this should be exposed,
i thankfully arrived at the right interface/naming, going with
the same API-naming/semantics as in all other libs:
So it's simple; we offer,
- a new
tractor.to_actor submod with equivalent convenience
invocation fns,
TDLR justification and premises
ToDo
I've rambled on wayyy too long in #287 but thanks to attempts to
resolve that issue I think this is the way I'd like to go on a so
called one shot task per actor-style "worker pool" API.
Proposed re-factored "one-shot" style API
After (too) much thought about where/how this should be exposed,
i thankfully arrived at the right interface/naming, going with
the same API-naming/semantics as in all other libs:
trio.to_threadanyio.to_threadanyio.to_processtrio_parallel.run_syncSo it's simple; we offer,
tractor.to_actorsubmod with equivalent convenienceinvocation fns,
.to_actor.run()to run anasync def fn()as a one-offtrio.Taskin a single subactor.
.to_actor.run_sync()to run andef fn()sync fn equivalent?a follow-up.
TDLR justification and premises
Portal.result()+ActorNursery.run_in_actor()couplesa future-like API into our nursery's actor spawning interface at
the wrong level of abstraction
.run_in_actor()can be implemented as a syntactic sugar on topof
ActorNursery.start_actor()+Portal.run()usingtriotasks in a similar way to our
concurrent.futuresworker poolexample
ActorNursery's teardown machineryis entirely superfluous and a path dependent legacy design which
has a few pretty awful side effects:
.run_in_actor()portals.run_in_actor()andPortal.run()trionursery machinery instead of rolling our own 😂)ToDo
figure out how to offer the higher level / new
.run_in_actor()API as a cluster helper.to_actorwhich exposes all proposed one-shot APIs:.run()for async sub-actor req/resp fn-style..run_sync()for sync equiv?regard the prior API-extension/sugar ideas around
.run_in_actor()-style butobvi design-n-implement on top of of this new API.
.run_in_actor()? #172.run_in_actor()remote task #287.run_in_actor()remote task #287 (comment).run_in_actor()is likely a bad API approach:.run_in_actor()remote task #287 (comment).run_in_actor()remote task #287 (comment).run_in_actor()remote task #287 (comment)allow easy selection of the
start_method: str(which ofc setsthe
._spawn._spawn_method: SpawnMethodKey) such that callerscan spec which backend to employ.
convert all
test_cancellation(mostlynested_multierrors()) suites to use the.open_context()/.run()style and ensure we can still get as reliable of performance