Add very basic exception handling

This commit is contained in:
Matthias 2022-11-07 07:07:15 +01:00
parent f9524aebe9
commit 60cfda5d52

View File

@ -6,6 +6,8 @@ from datetime import datetime
from threading import Thread from threading import Thread
from typing import Dict, List, Set, Tuple from typing import Dict, List, Set, Tuple
import ccxt
from freqtrade.constants import Config from freqtrade.constants import Config
from freqtrade.enums.candletype import CandleType from freqtrade.enums.candletype import CandleType
from freqtrade.exchange.exchange import timeframe_to_seconds from freqtrade.exchange.exchange import timeframe_to_seconds
@ -70,13 +72,18 @@ class ExchangeWS():
async def continuously_async_watch_ohlcv( async def continuously_async_watch_ohlcv(
self, pair: str, timeframe: str, candle_type: CandleType) -> None: self, pair: str, timeframe: str, candle_type: CandleType) -> None:
try:
while (pair, timeframe, candle_type) in self._pairs_watching: while (pair, timeframe, candle_type) in self._pairs_watching:
start = time.time() start = time.time()
data = await self.ccxt_object.watch_ohlcv(pair, timeframe) data = await self.ccxt_object.watch_ohlcv(pair, timeframe)
self.pairs_last_refresh[(pair, timeframe, candle_type)] = time.time() self.pairs_last_refresh[(pair, timeframe, candle_type)] = time.time()
# logger.info( # logger.info(
# f"watch done {pair}, {timeframe}, data {len(data)} in {time.time() - start:.2f}s") # f"watch done {pair}, {timeframe}, data {len(data)} "
# f"in {time.time() - start:.2f}s")
except ccxt.BaseError:
logger.exception("Exception in continuously_async_watch_ohlcv")
finally:
self._pairs_watching.discard((pair, timeframe, candle_type))
def schedule_ohlcv(self, pair: str, timeframe: str, candle_type: CandleType) -> None: def schedule_ohlcv(self, pair: str, timeframe: str, candle_type: CandleType) -> None:
self._pairs_watching.add((pair, timeframe, candle_type)) self._pairs_watching.add((pair, timeframe, candle_type))