Fix read response logic

This commit is contained in:
Logan Cusano
2025-05-25 22:02:46 -04:00
parent f46f7d6160
commit de6a547f4f

View File

@@ -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)