From b5b1c22d8a02e653af4958368305f6fee3b5fad3 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 2 May 2024 18:45:05 -0700 Subject: [PATCH] this forever hangs you disconnect (or 2 hours) --- selfdrive/athena/athenad.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 989e284e74..a93a3ecc5d 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -657,10 +657,12 @@ def stat_handler(end_event: threading.Event) -> None: def ws_proxy_recv(ws: WebSocket, local_sock: socket.socket, ssock: socket.socket, end_event: threading.Event, global_end_event: threading.Event) -> None: while not (end_event.is_set() or global_end_event.is_set()): try: - data = ws.recv() - if isinstance(data, str): - data = data.encode("utf-8") - local_sock.sendall(data) + r = select.select([ws], [], [], 10) + if r[0]: + data = ws.recv() + if isinstance(data, str): + data = data.encode("utf-8") + local_sock.sendall(data) except WebSocketTimeoutException: pass except Exception: @@ -670,6 +672,7 @@ def ws_proxy_recv(ws: WebSocket, local_sock: socket.socket, ssock: socket.socket cloudlog.debug("athena.ws_proxy_recv closing sockets") ssock.close() local_sock.close() + ws.close() cloudlog.debug("athena.ws_proxy_recv done closing sockets") end_event.set()