Fix read response logic
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user