Compare commits
3 Commits
08f7a3a9b8
...
d89ece08e4
| Author | SHA1 | Date |
|---|---|---|
|
|
d89ece08e4 | |
|
|
7ae8ddfb2c | |
|
|
9f36e743a9 |
|
|
@ -20,6 +20,18 @@ 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,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,17 @@ 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,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ 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(
|
||||||
|
|
|
||||||
|
|
@ -172,24 +172,36 @@ class Address(Protocol):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
_address_types: bidict[str, Type[Address]] = {
|
# the address types available on this host: TCP always, UDS only
|
||||||
'tcp': TCPAddress,
|
# where usable (`HAS_UDS`). Both registries derive from this single
|
||||||
}
|
# list via each type's `proto_key`.
|
||||||
|
_address_protos: list[Type[Address]] = [TCPAddress]
|
||||||
if HAS_UDS:
|
if HAS_UDS:
|
||||||
_address_types['uds'] = UDSAddress
|
_address_protos.append(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] = {
|
||||||
'tcp': TCPAddress.get_root().unwrap(),
|
cls.proto_key: cls.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]:
|
||||||
return _address_types[name]
|
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'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_wrapped_addr(addr: any) -> bool:
|
def is_wrapped_addr(addr: any) -> bool:
|
||||||
|
|
@ -287,7 +299,14 @@ def default_lo_addrs(
|
||||||
for an input transport key set.
|
for an input transport key set.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
return [
|
lo_addrs: list[UnwrappedAddress] = []
|
||||||
_default_lo_addrs[transport]
|
for transport in transports:
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -41,26 +41,28 @@ 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
|
||||||
|
|
||||||
# manually updated list of all supported msg transport types
|
# 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.
|
||||||
_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` to its `MsgTransport` type
|
# map a `MsgTransportKey` -> `MsgTransport` type
|
||||||
_key_to_transport: dict[MsgTransportKey, Type[MsgTransport]] = {
|
_key_to_transport: dict[MsgTransportKey, Type[MsgTransport]] = {
|
||||||
('msgpack', 'tcp'): MsgpackTCPStream,
|
(t.codec_key, t.address_type.proto_key): t
|
||||||
|
for t in _msg_transports
|
||||||
}
|
}
|
||||||
if HAS_UDS:
|
|
||||||
_key_to_transport[('msgpack', 'uds')] = MsgpackUDSStream
|
|
||||||
|
|
||||||
# map an `Address`-wrapper to its `MsgTransport` type
|
# map an `Address`-wrapper -> `MsgTransport` type
|
||||||
_addr_to_transport: dict[Type[Address], Type[MsgTransport]] = {
|
_addr_to_transport: dict[Type[Address], Type[MsgTransport]] = {
|
||||||
TCPAddress: MsgpackTCPStream,
|
t.address_type: t
|
||||||
|
for t in _msg_transports
|
||||||
}
|
}
|
||||||
if HAS_UDS:
|
|
||||||
_addr_to_transport[UDSAddress] = MsgpackUDSStream
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue