Skip to content

Commit ab9a831

Browse files
committed
Add exp backoff to GQL
1 parent e500569 commit ab9a831

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

twitch.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,8 @@ async def gql_request(
15131513
self, ops: GQLOperation | list[GQLOperation]
15141514
) -> JsonType | list[JsonType]:
15151515
gql_logger.debug(f"GQL Request: {ops}")
1516-
while True:
1516+
backoff = ExponentialBackoff(maximum=60)
1517+
for delay in backoff:
15171518
try:
15181519
auth_state = await self.get_auth()
15191520
async with self.request(
@@ -1552,7 +1553,8 @@ async def gql_request(
15521553
break
15531554
else:
15541555
return orig_response
1555-
await asyncio.sleep(1)
1556+
await asyncio.sleep(delay)
1557+
raise MinerException()
15561558

15571559
def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType:
15581560
merged = {}

0 commit comments

Comments
 (0)