Compare commits

..

No commits in common. "d89ece08e4ed3626d3d9f4dab13d23caf19fa959" and "08f7a3a9b83b9935f9798d6a5d4a6fd727658923" have entirely different histories.

5 changed files with 21 additions and 70 deletions

View File

@ -20,18 +20,6 @@ from typing import (
import pytest import pytest
import trio import trio
import tractor import tractor
# `infect_asyncio` mode is unsupported on Windows (asyncio's
# `ProactorEventLoop` is incompatible with our `trio` guest-mode
# interop and currently hangs/crashes the run). Skip the module on
# Windows so the CI leg completes + reports the rest of the suite.
import platform
if platform.system() == 'Windows':
pytest.skip(
'infect_asyncio mode is unsupported on Windows',
allow_module_level=True,
)
from tractor import ( from tractor import (
current_actor, current_actor,
Actor, Actor,

View File

@ -9,17 +9,6 @@ from functools import partial
import pytest import pytest
import trio import trio
import tractor import tractor
# `infect_asyncio` mode is unsupported on Windows (see
# `test_infected_asyncio`); skip at COLLECTION before the
# asyncio-interop imports below so the CI leg completes.
import platform
if platform.system() == 'Windows':
pytest.skip(
'infect_asyncio mode is unsupported on Windows',
allow_module_level=True,
)
from tractor import ( from tractor import (
to_asyncio, to_asyncio,
) )

View File

@ -73,11 +73,6 @@ async def test_lifetime_stack_wipes_tmpfile(
1.6 if error_in_child 1.6 if error_in_child
else 1 else 1
) )
# scale for slow/noisy CI (esp. macOS) so the child error
# propagates before the deadline; otherwise `move_on_after`
# cancels first and flips the `error_in_child=True` assert.
from .conftest import cpu_perf_headroom
timeout *= cpu_perf_headroom()
try: try:
with trio.move_on_after(timeout) as cs: with trio.move_on_after(timeout) as cs:
async with tractor.open_nursery( async with tractor.open_nursery(

View File

@ -172,36 +172,24 @@ class Address(Protocol):
... ...
# the address types available on this host: TCP always, UDS only _address_types: bidict[str, Type[Address]] = {
# where usable (`HAS_UDS`). Both registries derive from this single 'tcp': TCPAddress,
# list via each type's `proto_key`. }
_address_protos: list[Type[Address]] = [TCPAddress]
if HAS_UDS: if HAS_UDS:
_address_protos.append(UDSAddress) _address_types['uds'] = UDSAddress
_address_types: bidict[str, Type[Address]] = bidict({
cls.proto_key: cls
for cls in _address_protos
})
# TODO! really these are discovery sys default addrs ONLY useful for # TODO! really these are discovery sys default addrs ONLY useful for
# when none is provided to a root actor on first boot. # when none is provided to a root actor on first boot.
_default_lo_addrs: dict[str, UnwrappedAddress] = { _default_lo_addrs: dict[str, UnwrappedAddress] = {
cls.proto_key: cls.get_root().unwrap() 'tcp': TCPAddress.get_root().unwrap(),
for cls in _address_protos
} }
if HAS_UDS:
_default_lo_addrs['uds'] = UDSAddress.get_root().unwrap()
def get_address_cls(name: str) -> Type[Address]: def get_address_cls(name: str) -> Type[Address]:
try: return _address_types[name]
return _address_types[name]
except KeyError:
raise NotImplementedError(
f'No IPC transport backend for {name!r} on this '
f'platform!\n'
f'(available: {list(_address_types)})\n'
)
def is_wrapped_addr(addr: any) -> bool: def is_wrapped_addr(addr: any) -> bool:
@ -299,14 +287,7 @@ def default_lo_addrs(
for an input transport key set. for an input transport key set.
''' '''
lo_addrs: list[UnwrappedAddress] = [] return [
for transport in transports: _default_lo_addrs[transport]
try: for transport in transports
lo_addrs.append(_default_lo_addrs[transport]) ]
except KeyError:
raise NotImplementedError(
f'No default loopback addr for transport '
f'{transport!r} on this platform!\n'
f'(available: {list(_default_lo_addrs)})\n'
)
return lo_addrs

View File

@ -41,28 +41,26 @@ from tractor.ipc._uds import (
# hosts `HAS_UDS` is `False` and the runtime registers TCP only. # hosts `HAS_UDS` is `False` and the runtime registers TCP only.
Address = TCPAddress|UDSAddress Address = TCPAddress|UDSAddress
# the available msg-transport backends on this host: TCP always, # manually updated list of all supported msg transport types
# UDS only where usable (`HAS_UDS`). The lookup maps below are all
# DERIVED from this single list via each backend's ClassVars
# (`codec_key`, `address_type`) — register a backend here and every
# map picks it up; no per-map `if HAS_UDS` to keep in sync.
_msg_transports: list[Type[MsgTransport]] = [ _msg_transports: list[Type[MsgTransport]] = [
MsgpackTCPStream, MsgpackTCPStream,
] ]
if HAS_UDS: if HAS_UDS:
_msg_transports.append(MsgpackUDSStream) _msg_transports.append(MsgpackUDSStream)
# map a `MsgTransportKey` -> `MsgTransport` type # map a `MsgTransportKey` to its `MsgTransport` type
_key_to_transport: dict[MsgTransportKey, Type[MsgTransport]] = { _key_to_transport: dict[MsgTransportKey, Type[MsgTransport]] = {
(t.codec_key, t.address_type.proto_key): t ('msgpack', 'tcp'): MsgpackTCPStream,
for t in _msg_transports
} }
if HAS_UDS:
_key_to_transport[('msgpack', 'uds')] = MsgpackUDSStream
# map an `Address`-wrapper -> `MsgTransport` type # map an `Address`-wrapper to its `MsgTransport` type
_addr_to_transport: dict[Type[Address], Type[MsgTransport]] = { _addr_to_transport: dict[Type[Address], Type[MsgTransport]] = {
t.address_type: t TCPAddress: MsgpackTCPStream,
for t in _msg_transports
} }
if HAS_UDS:
_addr_to_transport[UDSAddress] = MsgpackUDSStream
# ------------------------------------------------------------ # ------------------------------------------------------------