catch TemporaryError for buy/sell in _process()

This commit is contained in:
gcarq 2018-04-22 20:28:39 +02:00
parent 4c49229b77
commit 5baab91bb5
2 changed files with 5 additions and 5 deletions

View File

@ -3,7 +3,6 @@ Freqtrade is the main module of this bot. It contains the class Freqtrade()
""" """
import copy import copy
import json
import logging import logging
import time import time
import traceback import traceback
@ -15,7 +14,8 @@ import requests
from cachetools import cached, TTLCache from cachetools import cached, TTLCache
from freqtrade import ( from freqtrade import (
DependencyException, OperationalException, exchange, persistence, __version__ DependencyException, OperationalException, TemporaryError,
exchange, persistence, __version__,
) )
from freqtrade.analyze import Analyze from freqtrade.analyze import Analyze
from freqtrade.constants import Constants from freqtrade.constants import Constants
@ -173,7 +173,7 @@ class FreqtradeBot(object):
self.check_handle_timedout(self.config['unfilledtimeout']) self.check_handle_timedout(self.config['unfilledtimeout'])
Trade.session.flush() Trade.session.flush()
except (requests.exceptions.RequestException, json.JSONDecodeError) as error: except TemporaryError as error:
logger.warning('%s, retrying in 30 seconds...', error) logger.warning('%s, retrying in 30 seconds...', error)
time.sleep(Constants.RETRY_TIMEOUT) time.sleep(Constants.RETRY_TIMEOUT)
except OperationalException: except OperationalException:

View File

@ -16,7 +16,7 @@ import pytest
import requests import requests
from sqlalchemy import create_engine from sqlalchemy import create_engine
from freqtrade import DependencyException, OperationalException from freqtrade import DependencyException, OperationalException, TemporaryError
from freqtrade.freqtradebot import FreqtradeBot from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.state import State from freqtrade.state import State
@ -451,7 +451,7 @@ def test_process_exchange_failures(default_conf, ticker, markets, mocker) -> Non
validate_pairs=MagicMock(), validate_pairs=MagicMock(),
get_ticker=ticker, get_ticker=ticker,
get_markets=markets, 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) sleep_mock = mocker.patch('time.sleep', side_effect=lambda _: None)