feat: Simplify reload_markets logic

This commit is contained in:
Matthias 2024-09-13 07:19:15 +02:00
parent 11eaa6d77c
commit 5112736385

View File

@ -661,13 +661,10 @@ class Exchange:
return None return None
logger.debug("Performing scheduled market reload..") logger.debug("Performing scheduled market reload..")
try: try:
# on initial load, we retry 3 times to ensure we get the markets
retries = 3 if force else 1
# Reload async markets, then assign them to sync api # Reload async markets, then assign them to sync api
if force: self._markets = retrier(self._load_async_markets, retries=retries)(reload=True)
# Force reload of markets - retry several times
self._markets = retrier(self._load_async_markets, retries=3)(reload=True)
else:
# Normal market reload - accept temporary errors and use "old" markets
self._markets = self._load_async_markets(reload=True)
self._api.set_markets(self._api_async.markets, self._api_async.currencies) self._api.set_markets(self._api_async.markets, self._api_async.currencies)
# Assign options array, as it contains some temporary information from the exchange. # Assign options array, as it contains some temporary information from the exchange.
self._api.options = self._api_async.options self._api.options = self._api_async.options