Clarify `run()` actor lifetime management

`run()` described its actor-selection kwargs as placement controls,
but they determine who owns the actor lifetime and whether an existing
actor is reused or a new one is spawned.

Use lifetime-management terminology in the parameter comments and
docstring, and identify the existing-actor handle as `portal: Portal`.

Review: PR #481 (goodboy)
https://github.com/goodboy/tractor/pull/481#pullrequestreview-5012942328

(this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`))
wkt/to_actor_subpkg
Gud Boi 2026-08-24 22:37:49 -04:00
parent 9373e9434d
commit 617ca1de43
1 changed files with 6 additions and 5 deletions

View File

@ -240,8 +240,8 @@ async def run(
fn: Callable[[Unpack[ArgsT]], Awaitable[RetT]], fn: Callable[[Unpack[ArgsT]], Awaitable[RetT]],
*args: Unpack[ArgsT], *args: Unpack[ArgsT],
# actor "placement": reuse an already-running peer # actor lifetime management: reuse an already-running peer
# via its `portal`, spawn a fresh subactor from # via its `portal: Portal`, spawn a fresh subactor from
# a caller-managed `an: ActorNursery`, or, when # a caller-managed `an: ActorNursery`, or, when
# neither is provided, open a private actor-nursery # neither is provided, open a private actor-nursery
# (implicitly booting the actor-runtime as needed) # (implicitly booting the actor-runtime as needed)
@ -275,9 +275,10 @@ async def run(
As with Trio's API, target arguments are positional. Use As with Trio's API, target arguments are positional. Use
`functools.partial()` to bind target keyword arguments; all `functools.partial()` to bind target keyword arguments; all
keyword arguments accepted here configure actor placement or keyword arguments accepted here configure actor lifetime
spawning. A caller-supplied `portal` must address an actor started management, including actor reuse and spawning. A caller-supplied
with both `tractor.to_actor.MODULE` and the target function's `portal` must address an actor started with both
`tractor.to_actor.MODULE` and the target function's
module in its `enable_modules` list. Calls that spawn their own module in its `enable_modules` list. Calls that spawn their own
actor add the trampoline module automatically. actor add the trampoline module automatically.