From dfc025499502de645677f1f162cf94776fe5fc65 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Wed, 2 Apr 2025 15:00:40 -0300 Subject: [PATCH] recv_fds doesnt need to be an acm --- tractor/ipc/_ringbuf/_ringd.py | 2 +- tractor/linux/_fdshare.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tractor/ipc/_ringbuf/_ringd.py b/tractor/ipc/_ringbuf/_ringd.py index a35de84b..0568771c 100644 --- a/tractor/ipc/_ringbuf/_ringd.py +++ b/tractor/ipc/_ringbuf/_ringd.py @@ -70,8 +70,8 @@ async def _attach_to_ring( name=ring_name, sock_path=sock_path ) as (ctx, token), - recv_fds(sock_path, fd_amount) as fds, ): + fds = await recv_fds(sock_path, fd_amount) log.info( f'received fds: {fds}' ) diff --git a/tractor/linux/_fdshare.py b/tractor/linux/_fdshare.py index 82dd0e69..e3817c34 100644 --- a/tractor/linux/_fdshare.py +++ b/tractor/linux/_fdshare.py @@ -29,10 +29,10 @@ async def send_fds(fds: list[int], sock_path: str): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) await sock.bind(sock_path) sock.listen(1) + yield fds = array.array('i', fds) # first byte of msg will be len of fds to send % 256 msg = bytes([len(fds) % 256]) - yield conn, _ = await sock.accept() await conn.sendmsg( [msg], @@ -46,7 +46,6 @@ async def send_fds(fds: list[int], sock_path: str): sock.close() -@acm async def recv_fds(sock_path: str, amount: int) -> tuple: stream = await trio.open_unix_socket(sock_path) sock = stream.socket @@ -87,8 +86,7 @@ async def recv_fds(sock_path: str, amount: int) -> tuple: ) ) - yield tuple(a) - return + return tuple(a) except (ValueError, IndexError): pass