Skip to content

Commit 29a0d3c

Browse files
committed
fix: log error as warning during WebSocket unsubscribe and close operations
1 parent fc73dfc commit 29a0d3c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

common/metric_types.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,18 @@ async def _collect_ws_data():
9292
finally:
9393
if websocket:
9494
try:
95-
# Shield cleanup from cancellation to ensure proper resource cleanup
9695
await asyncio.shield(self.unsubscribe(websocket))
96+
except asyncio.CancelledError:
97+
logging.info("Unsubscribe completed despite cancellation")
98+
except Exception as e:
99+
logging.warning(f"Error during unsubscribe (non-critical): {e!s}")
100+
101+
try:
97102
await asyncio.shield(websocket.close())
103+
except asyncio.CancelledError:
104+
logging.info("WebSocket close completed despite cancellation")
98105
except Exception as e:
99-
logging.error(f"Error closing websocket: {e!s}")
106+
logging.warning(f"Error closing websocket (non-critical): {e!s}")
100107

101108

102109
class HttpMetric(BaseMetric):

0 commit comments

Comments
 (0)