From 5baab91bb569072de2e738edba19a49eb2bc8ab7 Mon Sep 17 00:00:00 2001 From: gcarq Date: Sun, 22 Apr 2018 20:28:39 +0200 Subject: [PATCH] catch TemporaryError for buy/sell in _process() --- freqtrade/freqtradebot.py | 6 +++--- freqtrade/tests/test_freqtradebot.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 672090129..e780860e3 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -3,7 +3,6 @@ Freqtrade is the main module of this bot. It contains the class Freqtrade() """ import copy -import json import logging import time import traceback @@ -15,7 +14,8 @@ import requests from cachetools import cached, TTLCache from freqtrade import ( - DependencyException, OperationalException, exchange, persistence, __version__ + DependencyException, OperationalException, TemporaryError, + exchange, persistence, __version__, ) from freqtrade.analyze import Analyze from freqtrade.constants import Constants @@ -173,7 +173,7 @@ class FreqtradeBot(object): self.check_handle_timedout(self.config['unfilledtimeout']) Trade.session.flush() - except (requests.exceptions.RequestException, json.JSONDecodeError) as error: + except TemporaryError as error: logger.warning('%s, retrying in 30 seconds...', error) time.sleep(Constants.RETRY_TIMEOUT) except OperationalException: diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index d307c68aa..217bf82e6 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -16,7 +16,7 @@ import pytest import requests from sqlalchemy import create_engine -from freqtrade import DependencyException, OperationalException +from freqtrade import DependencyException, OperationalException, TemporaryError from freqtrade.freqtradebot import FreqtradeBot from freqtrade.persistence import Trade from freqtrade.state import State @@ -451,7 +451,7 @@ def test_process_exchange_failures(default_conf, ticker, markets, mocker) -> Non validate_pairs=MagicMock(), get_ticker=ticker, get_markets=markets, - buy=MagicMock(side_effect=requests.exceptions.RequestException) + buy=MagicMock(side_effect=TemporaryError) ) sleep_mock = mocker.patch('time.sleep', side_effect=lambda _: None)