From de6a547f4f508ab45b05e33dd92c209e8d7b52f4 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 25 May 2025 22:02:46 -0400 Subject: [PATCH] Fix read response logic --- app/routers/nodes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/routers/nodes.py b/app/routers/nodes.py index 090b00d..2766d8d 100644 --- a/app/routers/nodes.py +++ b/app/routers/nodes.py @@ -44,8 +44,13 @@ async def listen_to_client(websocket, client_id): request_id = data.get("request_id") if message_type == "response" and request_id in pending_requests: - future = pending_requests.pop(request_id) - if not future.done(): # Ensure the future hasn't been cancelled or set by something else + # Retrieve the dictionary containing the future and client_id + request_info = pending_requests.pop(request_id) + + # Extract the actual asyncio.Future object + future = request_info["future"] + + if not future.done(): # This will now correctly call .done() on the Future future.set_result(data.get("payload")) # Add other message types handling here if needed (e.g., unsolicited messages)