From 617ca1de43f1f2b66ec0f1b44f4e73afcee65c31 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 24 Aug 2026 22:37:49 -0400 Subject: [PATCH] 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`)) --- tractor/to_actor/_api.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tractor/to_actor/_api.py b/tractor/to_actor/_api.py index b145f3a0..66bd6ef8 100644 --- a/tractor/to_actor/_api.py +++ b/tractor/to_actor/_api.py @@ -240,8 +240,8 @@ async def run( fn: Callable[[Unpack[ArgsT]], Awaitable[RetT]], *args: Unpack[ArgsT], - # actor "placement": reuse an already-running peer - # via its `portal`, spawn a fresh subactor from + # actor lifetime management: reuse an already-running peer + # via its `portal: Portal`, spawn a fresh subactor from # a caller-managed `an: ActorNursery`, or, when # neither is provided, open a private actor-nursery # (implicitly booting the actor-runtime as needed) @@ -275,9 +275,10 @@ async def run( As with Trio's API, target arguments are positional. Use `functools.partial()` to bind target keyword arguments; all - keyword arguments accepted here configure actor placement or - spawning. A caller-supplied `portal` must address an actor started - with both `tractor.to_actor.MODULE` and the target function's + keyword arguments accepted here configure actor lifetime + management, including actor reuse and spawning. A caller-supplied + `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 actor add the trampoline module automatically.