Skip to content

Commit 77faf0b

Browse files
committed
optional endpoint
1 parent f832cf8 commit 77faf0b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lf_toolkit/rpc/ipc_listener_unix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import AsyncGenerator
2+
from typing import Optional
23

34
import anyio
45

@@ -12,8 +13,8 @@ class SocketListener(IPCListener):
1213

1314
endpoint: str
1415

15-
def __init__(self, endpoint: str):
16-
self.endpoint = endpoint
16+
def __init__(self, endpoint: Optional[str]):
17+
self.endpoint = endpoint if endpoint is not None else "/tmp/eval.sock"
1718

1819
async def listen(self) -> AsyncGenerator[IPCClient, None]:
1920
async with await anyio.create_unix_listener(self.endpoint) as listener:

lf_toolkit/rpc/ipc_listener_windows.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import AsyncGenerator
2+
from typing import Optional
23

34
import anyio
45
import pywintypes
@@ -13,8 +14,8 @@ class NamedPipeListener(IPCListener):
1314

1415
endpoint: str
1516

16-
def __init__(self, endpoint: str):
17-
self.endpoint = endpoint
17+
def __init__(self, endpoint: Optional[str] = None):
18+
self.endpoint = endpoint if endpoint is not None else r"\\.\pipe\eval"
1819

1920
async def listen(self) -> AsyncGenerator[IPCClient, None]:
2021
while True:

lf_toolkit/rpc/ipc_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .stream_io import StreamServer
1010

1111

12-
def default_ipc_listener_factory(endpoint: str) -> IPCListener:
12+
def default_ipc_listener_factory(endpoint: Optional[str]) -> IPCListener:
1313
if sys.platform == "win32":
1414
from .ipc_listener_windows import NamedPipeListener
1515

@@ -27,7 +27,7 @@ class IPCServer(StreamServer):
2727

2828
def __init__(
2929
self,
30-
endpoint: str,
30+
endpoint: Optional[str] = None,
3131
handler: Optional[RpcHandler] = None,
3232
listener_factory=default_ipc_listener_factory,
3333
):

0 commit comments

Comments
 (0)