diff --git a/freqtrade/exchange/exchange_ws.py b/freqtrade/exchange/exchange_ws.py index 70a373781..be99cb30f 100644 --- a/freqtrade/exchange/exchange_ws.py +++ b/freqtrade/exchange/exchange_ws.py @@ -55,8 +55,12 @@ class ExchangeWS: logger.debug("Stopped") async def _cleanup_async(self) -> None: - await self.ccxt_object.close() - self.__cleanup_called = True + try: + await self.ccxt_object.close() + except Exception: + logger.exception("Exception in _cleanup_async") + finally: + self.__cleanup_called = True def cleanup_expired(self) -> None: """ diff --git a/tests/exchange/test_exchange_ws.py b/tests/exchange/test_exchange_ws.py index c6684b250..5e93de1f4 100644 --- a/tests/exchange/test_exchange_ws.py +++ b/tests/exchange/test_exchange_ws.py @@ -46,6 +46,7 @@ async def test_exchangews_ohlcv(mocker): config = MagicMock() ccxt_object = MagicMock() ccxt_object.watch_ohlcv = AsyncMock() + ccxt_object.close = AsyncMock() mocker.patch("freqtrade.exchange.exchange_ws.ExchangeWS._start_forever", MagicMock()) exchange_ws = ExchangeWS(config, ccxt_object)