Add exp backoff to GQL
This commit is contained in:
1 parent
e500569c33
commit
ab9a8312ce
1 file changed
+4
-2
@@ -1513,7 +1513,8 @@ class Twitch:
|
|||||||
self, ops: GQLOperation | list[GQLOperation]
|
self, ops: GQLOperation | list[GQLOperation]
|
||||||
) -> JsonType | list[JsonType]:
|
) -> JsonType | list[JsonType]:
|
||||||
gql_logger.debug(f"GQL Request: {ops}")
|
gql_logger.debug(f"GQL Request: {ops}")
|
||||||
while True:
|
backoff = ExponentialBackoff(maximum=60)
|
||||||
|
for delay in backoff:
|
||||||
try:
|
try:
|
||||||
auth_state = await self.get_auth()
|
auth_state = await self.get_auth()
|
||||||
async with self.request(
|
async with self.request(
|
||||||
@@ -1552,7 +1553,8 @@ class Twitch:
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return orig_response
|
return orig_response
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(delay)
|
||||||
|
raise MinerException()
|
||||||
|
|
||||||
def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType:
|
def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType:
|
||||||
merged = {}
|
merged = {}
|
||||||
|
|||||||
Reference in new issue
Block a user