s/`._addr.preferred_transport`/`_state._def_tpt_proto`
Such that the "global-ish" setting (actor-local) is managed with the others per actor-process and type it as a `Literal['tcp', 'uds']` of the currently support protocol keys. Here obvi `_tpt` is some kinda shorthand for "transport" and `_proto` is for "protocol" Bp Change imports and refs in all dependent modules. Oh right, and disable UDS in `wrap_address()` for the moment while i figure out how to avoid the unwrapped type collision..leslies_extra_appendix
parent
a99bec63a3
commit
69fbe49d37
|
@ -40,6 +40,7 @@ from ._state import (
|
|||
get_rt_dir,
|
||||
current_actor,
|
||||
is_root_process,
|
||||
_def_tpt_proto,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -461,9 +462,6 @@ class UDSAddress(Address):
|
|||
os.unlink(self.sockpath)
|
||||
|
||||
|
||||
preferred_transport: str = 'uds'
|
||||
|
||||
|
||||
_address_types: bidict[str, Type[Address]] = {
|
||||
'tcp': TCPAddress,
|
||||
'uds': UDSAddress
|
||||
|
@ -525,11 +523,11 @@ def wrap_address(
|
|||
# TODO! BUT THIS WILL MATCH FOR TCP !...
|
||||
# -[ ] so prolly go back to what guille had orig XD
|
||||
# a plain ol' `str`?
|
||||
case ((
|
||||
str()|Path(),
|
||||
int(),
|
||||
)):
|
||||
cls = UDSAddress
|
||||
# case ((
|
||||
# str()|Path(),
|
||||
# int(),
|
||||
# )):
|
||||
# cls = UDSAddress
|
||||
|
||||
# classic network socket-address as tuple/list
|
||||
case (
|
||||
|
@ -541,12 +539,14 @@ def wrap_address(
|
|||
|
||||
# likely an unset UDS or TCP reg address as defaulted in
|
||||
# `_state._runtime_vars['_root_mailbox']`
|
||||
#
|
||||
# TODO? figure out when/if we even need this?
|
||||
case (
|
||||
None
|
||||
|
|
||||
[None, None]
|
||||
):
|
||||
cls: Type[Address] = get_address_cls(preferred_transport)
|
||||
cls: Type[Address] = get_address_cls(_def_tpt_proto)
|
||||
addr: UnwrappedAddress = cls.get_root().unwrap()
|
||||
|
||||
case _:
|
||||
|
|
|
@ -33,7 +33,6 @@ from .ipc import _connect_chan, Channel
|
|||
from ._addr import (
|
||||
UnwrappedAddress,
|
||||
Address,
|
||||
preferred_transport,
|
||||
wrap_address
|
||||
)
|
||||
from ._portal import (
|
||||
|
@ -44,6 +43,7 @@ from ._portal import (
|
|||
from ._state import (
|
||||
current_actor,
|
||||
_runtime_vars,
|
||||
_def_tpt_proto,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -203,7 +203,7 @@ async def maybe_open_portal(
|
|||
async def find_actor(
|
||||
name: str,
|
||||
registry_addrs: list[UnwrappedAddress]|None = None,
|
||||
enable_transports: list[str] = [preferred_transport],
|
||||
enable_transports: list[str] = [_def_tpt_proto],
|
||||
|
||||
only_first: bool = True,
|
||||
raise_on_none: bool = False,
|
||||
|
|
|
@ -56,7 +56,6 @@ from ._addr import (
|
|||
UnwrappedAddress,
|
||||
default_lo_addrs,
|
||||
mk_uuid,
|
||||
preferred_transport,
|
||||
wrap_address,
|
||||
)
|
||||
from ._exceptions import (
|
||||
|
@ -139,6 +138,7 @@ async def maybe_block_bp(
|
|||
os.environ.pop('PYTHONBREAKPOINT', None)
|
||||
|
||||
|
||||
|
||||
@acm
|
||||
async def open_root_actor(
|
||||
*,
|
||||
|
@ -148,7 +148,9 @@ async def open_root_actor(
|
|||
# defaults are above
|
||||
arbiter_addr: tuple[UnwrappedAddress]|None = None,
|
||||
|
||||
enable_transports: list[str] = [preferred_transport],
|
||||
enable_transports: list[
|
||||
_state.TransportProtocolKey,
|
||||
] = [_state._def_tpt_proto],
|
||||
|
||||
name: str|None = 'root',
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ from ._addr import (
|
|||
Address,
|
||||
default_lo_addrs,
|
||||
get_address_cls,
|
||||
preferred_transport,
|
||||
wrap_address,
|
||||
)
|
||||
from ._context import (
|
||||
|
@ -1322,7 +1321,9 @@ class Actor:
|
|||
|
||||
'''
|
||||
if listen_addrs is None:
|
||||
listen_addrs = default_lo_addrs([preferred_transport])
|
||||
listen_addrs = default_lo_addrs([
|
||||
_state._def_tpt_proto
|
||||
])
|
||||
|
||||
else:
|
||||
listen_addrs: list[Address] = [
|
||||
|
@ -1846,7 +1847,7 @@ async def async_main(
|
|||
enable_transports: list[str] = (
|
||||
maybe_preferred_transports_says_rent
|
||||
or
|
||||
[preferred_transport]
|
||||
[_state._def_tpt_proto]
|
||||
)
|
||||
for transport_key in enable_transports:
|
||||
transport_cls: Type[Address] = get_address_cls(
|
||||
|
|
|
@ -26,6 +26,7 @@ import os
|
|||
from pathlib import Path
|
||||
from typing import (
|
||||
Any,
|
||||
Literal,
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
|
||||
|
@ -164,3 +165,11 @@ def get_rt_dir(
|
|||
if not rtdir.is_dir():
|
||||
rtdir.mkdir()
|
||||
return rtdir
|
||||
|
||||
|
||||
# default IPC transport protocol settings
|
||||
TransportProtocolKey = Literal[
|
||||
'tcp',
|
||||
'uds',
|
||||
]
|
||||
_def_tpt_proto: TransportProtocolKey = 'tcp'
|
||||
|
|
|
@ -34,7 +34,6 @@ import trio
|
|||
from .devx._debug import maybe_wait_for_debugger
|
||||
from ._addr import (
|
||||
UnwrappedAddress,
|
||||
preferred_transport,
|
||||
mk_uuid,
|
||||
)
|
||||
from ._state import current_actor, is_main_process
|
||||
|
@ -45,7 +44,9 @@ from ._exceptions import (
|
|||
is_multi_cancelled,
|
||||
ContextCancelled,
|
||||
)
|
||||
from ._root import open_root_actor
|
||||
from ._root import (
|
||||
open_root_actor,
|
||||
)
|
||||
from . import _state
|
||||
from . import _spawn
|
||||
|
||||
|
@ -138,7 +139,7 @@ class ActorNursery:
|
|||
|
||||
bind_addrs: list[UnwrappedAddress]|None = None,
|
||||
rpc_module_paths: list[str]|None = None,
|
||||
enable_transports: list[str] = [preferred_transport],
|
||||
enable_transports: list[str] = [_state._def_tpt_proto],
|
||||
enable_modules: list[str]|None = None,
|
||||
loglevel: str|None = None, # set log level per subactor
|
||||
debug_mode: bool|None = None,
|
||||
|
|
Loading…
Reference in New Issue