Fix site down detection logic

This commit is contained in:
DevilXD committed 2022-10-24 17:40:38 +02:00
1 parent b216d41492
commit 0f44aac5b8
1 file changed
+6 -6
+6 -6
View File
@@ -1025,12 +1025,12 @@ class Twitch:
if response is None: if response is None:
raise RuntimeError("Close request leak") raise RuntimeError("Close request leak")
logger.debug(f"Response: {response.status}: {response}") logger.debug(f"Response: {response.status}: {response}")
if response.status >= 500: if response.status < 500:
self.print(_("error", "site_down").format(seconds=round(delay))) # pre-read the response to avoid getting errors outside of the context manager
# pre-read the response to avoid getting errors outside of the context manager await response.read()
await response.read() yield response
yield response return
return self.print(_("error", "site_down").format(seconds=round(delay)))
except (aiohttp.ClientConnectionError, asyncio.TimeoutError): except (aiohttp.ClientConnectionError, asyncio.TimeoutError):
# just so that quick retries that often happen, aren't shown # just so that quick retries that often happen, aren't shown
if delay > 1: if delay > 1: