Add 5XX http code handling
This commit is contained in:
1 parent
0b32d09285
commit
fcbda8fea2
1 file changed
+9
-3
@@ -856,9 +856,15 @@ class Twitch:
|
|||||||
for attempt in range(attempts):
|
for attempt in range(attempts):
|
||||||
logger.debug(f"Request: ({method=}, {url=}, {attempts=}, {kwargs=})")
|
logger.debug(f"Request: ({method=}, {url=}, {attempts=}, {kwargs=})")
|
||||||
try:
|
try:
|
||||||
async with session.request(method, url, **kwargs) as response:
|
while True:
|
||||||
logger.debug(f"Response: {response.status}: {response}")
|
async with session.request(method, url, **kwargs) as response:
|
||||||
yield response
|
logger.debug(f"Response: {response.status}: {response}")
|
||||||
|
if response.status >= 500:
|
||||||
|
self.print("Twitter is down, retrying in 120 seconds...")
|
||||||
|
await asyncio.sleep(120)
|
||||||
|
continue
|
||||||
|
yield response
|
||||||
|
break
|
||||||
return
|
return
|
||||||
except aiohttp.ClientConnectionError as exc:
|
except aiohttp.ClientConnectionError as exc:
|
||||||
cause = exc
|
cause = exc
|
||||||
|
|||||||
Reference in new issue
Block a user