fix uncaught exchange rate manager errors when going offline

This commit is contained in:
Jack Robison 2019-08-21 14:26:52 -04:00
parent 6b1f88df66
commit 48b4b97132
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -3,7 +3,8 @@ import time
import logging
import json
from decimal import Decimal
from typing import Optional
from aiohttp.client_exceptions import ClientError
from lbry.error import InvalidExchangeRateResponse, CurrencyConversionError
from lbry.utils import aiohttp_request
@ -44,7 +45,7 @@ class MarketFeed:
self.params = params
self.fee = fee
self.rate = None
self._task: asyncio.Task = None
self._task: Optional[asyncio.Task] = None
self._online = True
def rate_is_initialized(self):
@ -80,7 +81,7 @@ class MarketFeed:
try:
response = await asyncio.wait_for(self._make_request(), self.REQUESTS_TIMEOUT)
self._save_price(self._subtract_fee(self._handle_response(response)))
except (asyncio.TimeoutError, InvalidExchangeRateResponse) as err:
except (asyncio.TimeoutError, InvalidExchangeRateResponse, ClientError) as err:
self._on_error(err)
await asyncio.sleep(self.EXCHANGE_RATE_UPDATE_RATE_SEC)