From 48b4b9713249278e9ec28a6d266f1ae6da250ff0 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 21 Aug 2019 14:26:52 -0400 Subject: [PATCH] fix uncaught exchange rate manager errors when going offline --- lbry/lbry/extras/daemon/exchange_rate_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lbry/lbry/extras/daemon/exchange_rate_manager.py b/lbry/lbry/extras/daemon/exchange_rate_manager.py index f15d14478..bf784920d 100644 --- a/lbry/lbry/extras/daemon/exchange_rate_manager.py +++ b/lbry/lbry/extras/daemon/exchange_rate_manager.py @@ -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)