From 0bc18ea33c4004939acb62997a8e253b5ba2c08e Mon Sep 17 00:00:00 2001 From: Timothy Pogue Date: Sat, 10 Sep 2022 15:12:18 -0600 Subject: [PATCH] call websocket close in channel close --- freqtrade/rpc/api_server/ws/channel.py | 1 + freqtrade/rpc/api_server/ws/proxy.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/freqtrade/rpc/api_server/ws/channel.py b/freqtrade/rpc/api_server/ws/channel.py index cffe3092d..f4a0da47b 100644 --- a/freqtrade/rpc/api_server/ws/channel.py +++ b/freqtrade/rpc/api_server/ws/channel.py @@ -71,6 +71,7 @@ class WebSocketChannel: Close the WebSocketChannel """ + await self._websocket.close() self._closed = True def is_closed(self) -> bool: diff --git a/freqtrade/rpc/api_server/ws/proxy.py b/freqtrade/rpc/api_server/ws/proxy.py index da3e04887..2e5a59f05 100644 --- a/freqtrade/rpc/api_server/ws/proxy.py +++ b/freqtrade/rpc/api_server/ws/proxy.py @@ -56,8 +56,10 @@ class WebSocketProxy: Close the websocket connection, only supported by FastAPI WebSockets """ if hasattr(self._websocket, "close"): - return await self._websocket.close(code) - pass + try: + return await self._websocket.close(code) + except RuntimeError: + pass async def accept(self): """ @@ -65,4 +67,3 @@ class WebSocketProxy: """ if hasattr(self._websocket, "accept"): return await self._websocket.accept() - pass