Strengthen retry case and add comments

small_kucoin_fixes
jaredgoldman 2023-03-20 21:24:23 -04:00
parent 7bdebd47d1
commit 32107d0ac3
1 changed files with 4 additions and 1 deletions

View File

@ -343,6 +343,7 @@ class Client:
url = f"/market/candles?type={type}&symbol={kucoin_sym}&startAt={start_dt}&endAt={end_dt}"
bars = []
for i in range(10):
res = await self._request(
@ -350,7 +351,9 @@ class Client:
url,
api_v="v1",
)
if not isinstance(res, list):
if not isinstance(res, list) or not len(bars):
# Do a gradual backoff if Kucoin is rate limiting us
await trio.sleep(i + (randint(0, 1000) / 1000))
else:
bars = res