From 020a2e0e8995155e4d9d4d3ccf32fe7f0da88bad Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 23 Oct 2017 16:44:26 -0400 Subject: [PATCH] adjust the _online variable to be set on the errback, so any exception will set _online to False --- lbrynet/daemon/ExchangeRateManager.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lbrynet/daemon/ExchangeRateManager.py b/lbrynet/daemon/ExchangeRateManager.py index dfe02bbc1..339f09383 100644 --- a/lbrynet/daemon/ExchangeRateManager.py +++ b/lbrynet/daemon/ExchangeRateManager.py @@ -56,11 +56,7 @@ class MarketFeed(object): def _make_request(self): r = requests.get(self.url, self.params, timeout=self.REQUESTS_TIMEOUT) - if r.status_code == 200: - self._online = True - return r.text - self._online = False - return "" + return r.text def _handle_response(self, response): return NotImplementedError @@ -72,18 +68,20 @@ class MarketFeed(object): def _save_price(self, price): log.debug("Saving price update %f for %s from %s" % (price, self.market, self.name)) self.rate = ExchangeRate(self.market, price, int(time.time())) + self._online = True - def _log_error(self, err): + def _on_error(self, err): log.warning( "There was a problem updating %s exchange rate information from %s: %s", self.market, self.name, err) + self._online = False def _update_price(self): d = threads.deferToThread(self._make_request) d.addCallback(self._handle_response) d.addCallback(self._subtract_fee) d.addCallback(self._save_price) - d.addErrback(self._log_error) + d.addErrback(self._on_error) return d def start(self):