Feat: add SLM live monitoring improvements #60
@@ -269,10 +269,15 @@ async def proxy_websocket_monitor(websocket: WebSocket, unit_id: str):
|
|||||||
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
|
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
|
||||||
for t in pending:
|
for t in pending:
|
||||||
t.cancel()
|
t.cancel()
|
||||||
for t in pending:
|
# Await ALL tasks (the done one AND the cancelled one) and swallow both
|
||||||
|
# the expected WebSocketDisconnect and CancelledError. CancelledError is a
|
||||||
|
# BaseException, so a bare `except Exception` misses it — that's what leaked
|
||||||
|
# the traceback on stop; and awaiting only `pending` left the done task's
|
||||||
|
# exception unretrieved.
|
||||||
|
for t in tasks:
|
||||||
try:
|
try:
|
||||||
await t
|
await t
|
||||||
except Exception:
|
except (asyncio.CancelledError, Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except websockets.exceptions.WebSocketException as e:
|
except websockets.exceptions.WebSocketException as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user