Compare commits
2 Commits
aaba298361
...
1dd9c4ae75
Author | SHA1 | Date |
---|---|---|
|
1dd9c4ae75 | |
|
8dd7bc0ba9 |
|
@ -939,6 +939,7 @@ async def tell_little_bro(
|
||||||
def test_peer_spawns_and_cancels_service_subactor(
|
def test_peer_spawns_and_cancels_service_subactor(
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
raise_client_error: str,
|
raise_client_error: str,
|
||||||
|
reg_addr: tuple[str, int],
|
||||||
):
|
):
|
||||||
# NOTE: this tests for the modden `mod wks open piker` bug
|
# NOTE: this tests for the modden `mod wks open piker` bug
|
||||||
# discovered as part of implementing workspace ctx
|
# discovered as part of implementing workspace ctx
|
||||||
|
@ -956,6 +957,7 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
# NOTE: to halt the peer tasks on ctxc, uncomment this.
|
# NOTE: to halt the peer tasks on ctxc, uncomment this.
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
|
registry_addrs=[reg_addr],
|
||||||
) as an:
|
) as an:
|
||||||
server: Portal = await an.start_actor(
|
server: Portal = await an.start_actor(
|
||||||
(server_name := 'spawn_server'),
|
(server_name := 'spawn_server'),
|
||||||
|
|
|
@ -35,7 +35,10 @@ from ._portal import (
|
||||||
open_portal,
|
open_portal,
|
||||||
LocalPortal,
|
LocalPortal,
|
||||||
)
|
)
|
||||||
from ._state import current_actor, _runtime_vars
|
from ._state import (
|
||||||
|
current_actor,
|
||||||
|
_runtime_vars,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -159,8 +162,8 @@ async def query_actor(
|
||||||
@acm
|
@acm
|
||||||
async def find_actor(
|
async def find_actor(
|
||||||
name: str,
|
name: str,
|
||||||
arbiter_sockaddr: tuple[str, int] | None = None,
|
arbiter_sockaddr: tuple[str, int]|None = None,
|
||||||
registry_addrs: list[tuple[str, int]] | None = None,
|
registry_addrs: list[tuple[str, int]]|None = None,
|
||||||
|
|
||||||
only_first: bool = True,
|
only_first: bool = True,
|
||||||
raise_on_none: bool = False,
|
raise_on_none: bool = False,
|
||||||
|
@ -205,7 +208,11 @@ async def find_actor(
|
||||||
# every call since something may change it globally (eg.
|
# every call since something may change it globally (eg.
|
||||||
# like in our discovery test suite)!
|
# like in our discovery test suite)!
|
||||||
from . import _root
|
from . import _root
|
||||||
registry_addrs = _root._default_lo_addrs
|
registry_addrs = (
|
||||||
|
_runtime_vars['_registry_addrs']
|
||||||
|
or
|
||||||
|
_root._default_lo_addrs
|
||||||
|
)
|
||||||
|
|
||||||
maybe_portals: list[
|
maybe_portals: list[
|
||||||
AsyncContextManager[tuple[str, int]]
|
AsyncContextManager[tuple[str, int]]
|
||||||
|
|
|
@ -64,26 +64,26 @@ async def open_root_actor(
|
||||||
|
|
||||||
*,
|
*,
|
||||||
# defaults are above
|
# defaults are above
|
||||||
registry_addrs: list[tuple[str, int]] | None = None,
|
registry_addrs: list[tuple[str, int]]|None = None,
|
||||||
|
|
||||||
# defaults are above
|
# defaults are above
|
||||||
arbiter_addr: tuple[str, int] | None = None,
|
arbiter_addr: tuple[str, int]|None = None,
|
||||||
|
|
||||||
name: str | None = 'root',
|
name: str|None = 'root',
|
||||||
|
|
||||||
# either the `multiprocessing` start method:
|
# either the `multiprocessing` start method:
|
||||||
# https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
# https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
||||||
# OR `trio` (the new default).
|
# OR `trio` (the new default).
|
||||||
start_method: _spawn.SpawnMethodKey | None = None,
|
start_method: _spawn.SpawnMethodKey|None = None,
|
||||||
|
|
||||||
# enables the multi-process debugger support
|
# enables the multi-process debugger support
|
||||||
debug_mode: bool = False,
|
debug_mode: bool = False,
|
||||||
|
|
||||||
# internal logging
|
# internal logging
|
||||||
loglevel: str | None = None,
|
loglevel: str|None = None,
|
||||||
|
|
||||||
enable_modules: list | None = None,
|
enable_modules: list|None = None,
|
||||||
rpc_module_paths: list | None = None,
|
rpc_module_paths: list|None = None,
|
||||||
|
|
||||||
# NOTE: allow caller to ensure that only one registry exists
|
# NOTE: allow caller to ensure that only one registry exists
|
||||||
# and that this call creates it.
|
# and that this call creates it.
|
||||||
|
@ -109,7 +109,11 @@ async def open_root_actor(
|
||||||
_state._runtime_vars['_is_root'] = True
|
_state._runtime_vars['_is_root'] = True
|
||||||
|
|
||||||
# caps based rpc list
|
# caps based rpc list
|
||||||
enable_modules = enable_modules or []
|
enable_modules = (
|
||||||
|
enable_modules
|
||||||
|
or
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
if rpc_module_paths:
|
if rpc_module_paths:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
|
|
|
@ -168,10 +168,10 @@ class Actor:
|
||||||
name: str,
|
name: str,
|
||||||
*,
|
*,
|
||||||
enable_modules: list[str] = [],
|
enable_modules: list[str] = [],
|
||||||
uid: str | None = None,
|
uid: str|None = None,
|
||||||
loglevel: str | None = None,
|
loglevel: str|None = None,
|
||||||
registry_addrs: list[tuple[str, int]] | None = None,
|
registry_addrs: list[tuple[str, int]]|None = None,
|
||||||
spawn_method: str | None = None,
|
spawn_method: str|None = None,
|
||||||
|
|
||||||
# TODO: remove!
|
# TODO: remove!
|
||||||
arbiter_addr: tuple[str, int] | None = None,
|
arbiter_addr: tuple[str, int] | None = None,
|
||||||
|
@ -257,6 +257,7 @@ class Actor:
|
||||||
self._reg_addrs: list[tuple[str, int]] = []
|
self._reg_addrs: list[tuple[str, int]] = []
|
||||||
if registry_addrs:
|
if registry_addrs:
|
||||||
self.reg_addrs: list[tuple[str, int]] = registry_addrs
|
self.reg_addrs: list[tuple[str, int]] = registry_addrs
|
||||||
|
_state._runtime_vars['_registry_addrs'] = registry_addrs
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def reg_addrs(self) -> list[tuple[str, int]]:
|
def reg_addrs(self) -> list[tuple[str, int]]:
|
||||||
|
|
|
@ -33,7 +33,8 @@ _last_actor_terminated: Actor|None = None
|
||||||
_runtime_vars: dict[str, Any] = {
|
_runtime_vars: dict[str, Any] = {
|
||||||
'_debug_mode': False,
|
'_debug_mode': False,
|
||||||
'_is_root': False,
|
'_is_root': False,
|
||||||
'_root_mailbox': (None, None)
|
'_root_mailbox': (None, None),
|
||||||
|
'_registry_addrs': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue