diff --git a/twitch.py b/twitch.py index 9a33d00..5daf172 100644 --- a/twitch.py +++ b/twitch.py @@ -856,9 +856,15 @@ class Twitch: for attempt in range(attempts): logger.debug(f"Request: ({method=}, {url=}, {attempts=}, {kwargs=})") try: - async with session.request(method, url, **kwargs) as response: - logger.debug(f"Response: {response.status}: {response}") - yield response + while True: + async with session.request(method, url, **kwargs) as 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 except aiohttp.ClientConnectionError as exc: cause = exc