Update tests+examples imports for new subpkgs

Adjust all `tractor._state`, `tractor._addr`,
`tractor._supervise`, etc. refs in tests and examples
to use the new `runtime/`, `discovery/`, `spawn/` paths.

Also,
- use `tractor.debug_mode()` pub API instead of
  `tractor._state.debug_mode()` in a few test mods
- add explicit `timeout=20` to `test_respawn_consumer_task`
  `@tractor_test` deco call

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
multicast_revertable_streams
Gud Boi 2026-03-23 18:44:14 -04:00
parent cc42d38284
commit f3441a6790
12 changed files with 25 additions and 26 deletions

View File

@ -20,7 +20,7 @@ async def sleep(
async def open_ctx( async def open_ctx(
n: tractor._supervise.ActorNursery n: tractor.runtime._supervise.ActorNursery
): ):
# spawn both actors # spawn both actors

View File

@ -126,7 +126,7 @@ def test_shield_pause(
child.pid, child.pid,
signal.SIGINT, signal.SIGINT,
) )
from tractor._supervise import _shutdown_msg from tractor.runtime._supervise import _shutdown_msg
expect( expect(
child, child,
# 'Shutting down actor runtime', # 'Shutting down actor runtime',

View File

@ -8,17 +8,16 @@ from pathlib import Path
import pytest import pytest
import trio import trio
import tractor import tractor
from tractor import ( from tractor import Actor
Actor, from tractor.runtime import _state
_state, from tractor.discovery import _addr
_addr,
)
@pytest.fixture @pytest.fixture
def bindspace_dir_str() -> str: def bindspace_dir_str() -> str:
rt_dir: Path = tractor._state.get_rt_dir() from tractor.runtime._state import get_rt_dir
rt_dir: Path = get_rt_dir()
bs_dir: Path = rt_dir / 'doggy' bs_dir: Path = rt_dir / 'doggy'
bs_dir_str: str = str(bs_dir) bs_dir_str: str = str(bs_dir)
assert not bs_dir.is_dir() assert not bs_dir.is_dir()

View File

@ -13,9 +13,9 @@ from tractor import (
Portal, Portal,
ipc, ipc,
msg, msg,
_state,
_addr,
) )
from tractor.runtime import _state
from tractor.discovery import _addr
@tractor.context @tractor.context
async def chk_tpts( async def chk_tpts(

View File

@ -61,7 +61,7 @@ async def maybe_expect_raises(
Async wrapper for ensuring errors propagate from the inner scope. Async wrapper for ensuring errors propagate from the inner scope.
''' '''
if tractor._state.debug_mode(): if tractor.debug_mode():
timeout += 999 timeout += 999
with trio.fail_after(timeout): with trio.fail_after(timeout):

View File

@ -26,7 +26,7 @@ from tractor._exceptions import (
StreamOverrun, StreamOverrun,
ContextCancelled, ContextCancelled,
) )
from tractor._state import current_ipc_ctx from tractor.runtime._state import current_ipc_ctx
from tractor._testing import ( from tractor._testing import (
tractor_test, tractor_test,
@ -939,7 +939,7 @@ def test_one_end_stream_not_opened(
''' '''
overrunner, buf_size_increase, entrypoint = overrun_by overrunner, buf_size_increase, entrypoint = overrun_by
from tractor._runtime import Actor from tractor.runtime._runtime import Actor
buf_size = buf_size_increase + Actor.msg_buffer_size buf_size = buf_size_increase + Actor.msg_buffer_size
timeout: float = ( timeout: float = (

View File

@ -26,8 +26,8 @@ from tractor import (
to_asyncio, to_asyncio,
RemoteActorError, RemoteActorError,
ContextCancelled, ContextCancelled,
_state,
) )
from tractor.runtime import _state
from tractor.trionics import BroadcastReceiver from tractor.trionics import BroadcastReceiver
from tractor._testing import expect_ctxc from tractor._testing import expect_ctxc

View File

@ -201,7 +201,7 @@ async def stream_from_peer(
) -> None: ) -> None:
# sanity # sanity
assert tractor._state.debug_mode() == debug_mode assert tractor.debug_mode() == debug_mode
peer: Portal peer: Portal
try: try:
@ -841,7 +841,7 @@ async def serve_subactors(
async with open_nursery() as an: async with open_nursery() as an:
# sanity # sanity
assert tractor._state.debug_mode() == debug_mode assert tractor.debug_mode() == debug_mode
await ctx.started(peer_name) await ctx.started(peer_name)
async with ctx.open_stream() as ipc: async with ctx.open_stream() as ipc:
@ -880,7 +880,7 @@ async def client_req_subactor(
) -> None: ) -> None:
# sanity # sanity
if debug_mode: if debug_mode:
assert tractor._state.debug_mode() assert tractor.debug_mode()
# TODO: other cases to do with sub lifetimes: # TODO: other cases to do with sub lifetimes:
# -[ ] test that we can have the server spawn a sub # -[ ] test that we can have the server spawn a sub

View File

@ -353,7 +353,7 @@ def test_not_fast_enough_quad(
assert results is None assert results is None
@tractor_test @tractor_test(timeout=20)
async def test_respawn_consumer_task( async def test_respawn_consumer_task(
reg_addr: tuple, reg_addr: tuple,
spawn_backend: str, spawn_backend: str,

View File

@ -39,7 +39,7 @@ async def test_self_is_registered_localportal(reg_addr):
actor = tractor.current_actor() actor = tractor.current_actor()
assert actor.is_arbiter assert actor.is_arbiter
async with tractor.get_registry(reg_addr) as portal: async with tractor.get_registry(reg_addr) as portal:
assert isinstance(portal, tractor._portal.LocalPortal) assert isinstance(portal, tractor.runtime._portal.LocalPortal)
with trio.fail_after(0.2): with trio.fail_after(0.2):
sockaddr = await portal.run_from_ns( sockaddr = await portal.run_from_ns(

View File

@ -17,11 +17,11 @@ from tractor._testing import (
) )
from tractor import ( from tractor import (
current_actor, current_actor,
_state,
Actor, Actor,
Context, Context,
Portal, Portal,
) )
from tractor.runtime import _state
from .conftest import ( from .conftest import (
sig_prog, sig_prog,
_INT_SIGNAL, _INT_SIGNAL,
@ -30,7 +30,7 @@ from .conftest import (
if TYPE_CHECKING: if TYPE_CHECKING:
from tractor.msg import Aid from tractor.msg import Aid
from tractor._addr import ( from tractor.discovery._addr import (
UnwrappedAddress, UnwrappedAddress,
) )
@ -122,7 +122,7 @@ async def get_root_portal(
# connect back to our immediate parent which should also # connect back to our immediate parent which should also
# be the actor-tree's root. # be the actor-tree's root.
from tractor._discovery import get_root from tractor.discovery._discovery import get_root
ptl: Portal ptl: Portal
async with get_root() as ptl: async with get_root() as ptl:
root_aid: Aid = ptl.chan.aid root_aid: Aid = ptl.chan.aid

View File

@ -94,15 +94,15 @@ def test_runtime_vars_unset(
after the root actor-runtime exits! after the root actor-runtime exits!
''' '''
assert not tractor._state._runtime_vars['_debug_mode'] assert not tractor.runtime._state._runtime_vars['_debug_mode']
async def main(): async def main():
assert not tractor._state._runtime_vars['_debug_mode'] assert not tractor.runtime._state._runtime_vars['_debug_mode']
async with tractor.open_nursery( async with tractor.open_nursery(
debug_mode=True, debug_mode=True,
): ):
assert tractor._state._runtime_vars['_debug_mode'] assert tractor.runtime._state._runtime_vars['_debug_mode']
# after runtime closure, should be reverted! # after runtime closure, should be reverted!
assert not tractor._state._runtime_vars['_debug_mode'] assert not tractor.runtime._state._runtime_vars['_debug_mode']
trio.run(main) trio.run(main)