Assert `to_actor.run()` runtime lifecycle
The implicit-runtime test verified the caller started outside Tractor but did not prove that the target ran inside an actor or that the private runtime was gone when the call returned. Assert an active actor inside the shared remote target and assert the caller has no current actor again after the one-shot call completes. 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
parent
b58889f625
commit
a99a4c9353
|
|
@ -33,6 +33,13 @@ from ._helpers import (
|
||||||
async def add_one(
|
async def add_one(
|
||||||
n: int,
|
n: int,
|
||||||
) -> int:
|
) -> int:
|
||||||
|
'''
|
||||||
|
Increment within an active actor runtime.
|
||||||
|
|
||||||
|
'''
|
||||||
|
assert tractor.current_actor(
|
||||||
|
err_on_no_runtime=False,
|
||||||
|
) is not None
|
||||||
return n + 1
|
return n + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,7 +132,9 @@ def test_one_shot_boots_implicit_runtime(
|
||||||
'''
|
'''
|
||||||
Outside any actor-runtime `to_actor.run()` boots one
|
Outside any actor-runtime `to_actor.run()` boots one
|
||||||
implicitly (just like bare `open_nursery()` usage)
|
implicitly (just like bare `open_nursery()` usage)
|
||||||
configured via pass-through `runtime_kwargs`.
|
configured via pass-through `runtime_kwargs`. The remote target
|
||||||
|
asserts its runtime exists; the caller then verifies the private
|
||||||
|
runtime is fully torn down before `to_actor.run()` returns.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
|
|
@ -142,6 +151,9 @@ def test_one_shot_boots_implicit_runtime(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result == 42
|
assert result == 42
|
||||||
|
assert tractor.current_actor(
|
||||||
|
err_on_no_runtime=False,
|
||||||
|
) is None
|
||||||
|
|
||||||
trio.run(main)
|
trio.run(main)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue