From e44fa4f72b1068535bc7db4ac97fd419af464bc2 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 28 Jul 2025 15:48:40 +0530 Subject: [PATCH] Remove nested try block --- ws_proxy.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ws_proxy.py b/ws_proxy.py index f3141a5..9aeae94 100644 --- a/ws_proxy.py +++ b/ws_proxy.py @@ -31,17 +31,16 @@ class WebSocketProxy: provider_ws, provider_session = provider_connection - try: - await asyncio.gather( - self._proxy_client_to_provider(ws, provider_ws, provider), - self._proxy_provider_to_client(provider_ws, ws, provider), - return_exceptions=True - ) - finally: - # Clean up provider connection - if not provider_ws.closed: - await provider_ws.close() - await provider_session.close() + await asyncio.gather( + self._proxy_client_to_provider(ws, provider_ws, provider), + self._proxy_provider_to_client(provider_ws, ws, provider), + return_exceptions=True + ) + + # Clean up provider connection + if not provider_ws.closed: + await provider_ws.close() + await provider_session.close() except Exception as e: self.logger.error(f"WebSocket proxy error: {e}")