Compare commits

..

1 Commits

4 changed files with 19 additions and 19 deletions

View File

@ -21,12 +21,12 @@ from ._transport import MsgTransport as MsgTransport
from ._tcp import ( from ._tcp import (
get_stream_addrs as get_stream_addrs, get_stream_addrs as get_stream_addrs,
get_msg_transport as get_msg_transport,
MsgpackTCPStream as MsgpackTCPStream MsgpackTCPStream as MsgpackTCPStream
) )
from ._chan import ( from ._chan import (
_connect_chan as _connect_chan, _connect_chan as _connect_chan,
get_msg_transport as get_msg_transport,
Channel as Channel Channel as Channel
) )

View File

@ -29,14 +29,15 @@ from pprint import pformat
import typing import typing
from typing import ( from typing import (
Any, Any,
Type
) )
import trio import trio
from tractor.ipc import ( from tractor.ipc._transport import MsgTransport
MsgTransport, from tractor.ipc._tcp import (
get_stream_addrs, MsgpackTCPStream,
get_msg_transport get_stream_addrs
) )
from tractor.log import get_logger from tractor.log import get_logger
from tractor._exceptions import ( from tractor._exceptions import (
@ -51,6 +52,17 @@ log = get_logger(__name__)
_is_windows = platform.system() == 'Windows' _is_windows = platform.system() == 'Windows'
def get_msg_transport(
key: tuple[str, str],
) -> Type[MsgTransport]:
return {
('msgpack', 'tcp'): MsgpackTCPStream,
}[key]
class Channel: class Channel:
''' '''
An inter-process channel for communication between (remote) actors. An inter-process channel for communication between (remote) actors.

View File

@ -15,9 +15,8 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
TCP implementation of tractor.ipc._transport.MsgTransport protocol TCP implementation of tractor.ipc._transport.MsgTransport protocol
''' '''
from __future__ import annotations from __future__ import annotations
from collections.abc import ( from collections.abc import (
AsyncGenerator, AsyncGenerator,
@ -405,14 +404,3 @@ class MsgpackTCPStream(MsgTransport):
def connected(self) -> bool: def connected(self) -> bool:
return self.stream.socket.fileno() != -1 return self.stream.socket.fileno() != -1
def get_msg_transport(
key: tuple[str, str],
) -> Type[MsgTransport]:
return {
('msgpack', 'tcp'): MsgpackTCPStream,
}[key]

View File

@ -16,8 +16,8 @@
''' '''
typing.Protocol based generic msg API, implement this class to add backends for typing.Protocol based generic msg API, implement this class to add backends for
tractor.ipc.Channel tractor.ipc.Channel
'''
'''
import trio import trio
from typing import ( from typing import (
runtime_checkable, runtime_checkable,