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 trio
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 (
current_actor,
Actor,

View File

@ -9,17 +9,6 @@ from functools import partial
import pytest
import trio
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 (
to_asyncio,
)

View File

@ -73,11 +73,6 @@ async def test_lifetime_stack_wipes_tmpfile(
1.6 if error_in_child
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:
with trio.move_on_after(timeout) as cs:
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
# where usable (`HAS_UDS`). Both registries derive from this single
# list via each type's `proto_key`.
_address_protos: list[Type[Address]] = [TCPAddress]
_address_types: bidict[str, Type[Address]] = {
'tcp': TCPAddress,
}
if HAS_UDS:
_address_protos.append(UDSAddress)
_address_types: bidict[str, Type[Address]] = bidict({
cls.proto_key: cls
for cls in _address_protos
})
_address_types['uds'] = UDSAddress
# TODO! really these are discovery sys default addrs ONLY useful for
# when none is provided to a root actor on first boot.
_default_lo_addrs: dict[str, UnwrappedAddress] = {
cls.proto_key: cls.get_root().unwrap()
for cls in _address_protos
'tcp': TCPAddress.get_root().unwrap(),
}
if HAS_UDS:
_default_lo_addrs['uds'] = UDSAddress.get_root().unwrap()
def get_address_cls(name: str) -> Type[Address]:
try:
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'
)
return _address_types[name]
def is_wrapped_addr(addr: any) -> bool:
@ -299,14 +287,7 @@ def default_lo_addrs(
for an input transport key set.
'''
lo_addrs: list[UnwrappedAddress] = []
for transport in transports:
try:
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
return [
_default_lo_addrs[transport]
for transport in transports
]

View File

@ -41,28 +41,26 @@ from tractor.ipc._uds import (
# hosts `HAS_UDS` is `False` and the runtime registers TCP only.
Address = TCPAddress|UDSAddress
# the available msg-transport backends on this host: TCP always,
# 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.
# manually updated list of all supported msg transport types
_msg_transports: list[Type[MsgTransport]] = [
MsgpackTCPStream,
]
if HAS_UDS:
_msg_transports.append(MsgpackUDSStream)
# map a `MsgTransportKey` -> `MsgTransport` type
# map a `MsgTransportKey` to its `MsgTransport` type
_key_to_transport: dict[MsgTransportKey, Type[MsgTransport]] = {
(t.codec_key, t.address_type.proto_key): t
for t in _msg_transports
('msgpack', 'tcp'): MsgpackTCPStream,
}
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]] = {
t.address_type: t
for t in _msg_transports
TCPAddress: MsgpackTCPStream,
}
if HAS_UDS:
_addr_to_transport[UDSAddress] = MsgpackUDSStream
# ------------------------------------------------------------