Ensure shutdown of async exchange, fix test

This commit is contained in:
Matthias 2024-02-10 16:07:41 +01:00
parent d42e012ec3
commit 2ade5191e6
2 changed files with 7 additions and 2 deletions

View File

@ -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:
"""

View File

@ -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)