Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions common/metric_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,18 @@ async def _collect_ws_data():
finally:
if websocket:
try:
# Shield cleanup from cancellation to ensure proper resource cleanup
await asyncio.shield(self.unsubscribe(websocket))
except asyncio.CancelledError:
logging.info("Unsubscribe completed despite cancellation")
except Exception as e:
logging.warning(f"Error during unsubscribe (non-critical): {e!s}")

try:
await asyncio.shield(websocket.close())
except asyncio.CancelledError:
logging.info("WebSocket close completed despite cancellation")
except Exception as e:
logging.error(f"Error closing websocket: {e!s}")
logging.warning(f"Error closing websocket (non-critical): {e!s}")


class HttpMetric(BaseMetric):
Expand Down