Reduce more KuCoin logs on retrier decorator

More logs are reduced, for KuCoin, on the retrier_async decorator:

_async_get_candle_history() returned exception
retrying _async_get_candle_history() still for
Giving up retrying: _async_get_candle_history()
Applying DDosProtection backoff delay
This commit is contained in:
cdimauro
2021-12-26 09:06:26 +01:00
parent 96fbf63d0b
commit fbaf46901e
2 changed files with 37 additions and 7 deletions

View File

@@ -1757,7 +1757,30 @@ async def test__async_kucoin_get_candle_history(default_conf, mocker, caplog):
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kucoin")
await exchange._async_get_candle_history(
'ETH/BTC', "5m", (arrow.utcnow().int_timestamp - 2000) * 1000, count=1)
logs_found = sum('Kucoin 429 error, avoid triggering DDosProtection backoff delay' in message
logs_found = sum('_async_get_candle_history() returned exception: "kucoin GET ' in message
for message in caplog.messages)
assert logs_found == 1
logs_found = sum('retrying _async_get_candle_history() still for ' in message
for message in caplog.messages)
assert logs_found == 1
logs_found = sum("Kucoin 429 error, avoid triggering DDosProtection backoff delay" in message
for message in caplog.messages)
assert logs_found == 1
logs_found = sum(message == 'Giving up retrying: _async_get_candle_history()'
for message in caplog.messages)
assert logs_found == 1
mocker.patch('freqtrade.exchange.common.calculate_backoff', MagicMock(return_value=0.01))
for _ in range(3):
with pytest.raises(DDosProtection, match=r'XYZ Too Many Requests'):
api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.DDoSProtection(
"kucoin GET https://openapi-v2.kucoin.com/api/v1/market/candles?"
"symbol=ETH-BTC&type=5min&startAt=1640268735&endAt=1640418735"
"XYZ Too Many Requests" '{"code":"XYZ000","msg":"Too Many Requests"}'))
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kucoin")
await exchange._async_get_candle_history(
'ETH/BTC', "5m", (arrow.utcnow().int_timestamp - 2000) * 1000, count=1)
logs_found = sum('Applying DDosProtection backoff delay: ' in message
for message in caplog.messages)
assert logs_found == 1