Use exp. backoff for the twitch down delay
This commit is contained in:
1 parent
515c86d1fa
commit
1bb1450ce8
1 file changed
+4
-4
@@ -17,8 +17,8 @@ from gui import GUIManager
|
|||||||
from channel import Channel
|
from channel import Channel
|
||||||
from websocket import WebsocketPool
|
from websocket import WebsocketPool
|
||||||
from inventory import DropsCampaign
|
from inventory import DropsCampaign
|
||||||
from utils import task_wrapper, timestamp, AwaitableValue, OrderedSet
|
|
||||||
from exceptions import ExitRequest, RequestException, LoginException, CaptchaRequired
|
from exceptions import ExitRequest, RequestException, LoginException, CaptchaRequired
|
||||||
|
from utils import task_wrapper, timestamp, AwaitableValue, OrderedSet, ExponentialBackoff
|
||||||
from constants import (
|
from constants import (
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
CLIENT_ID,
|
CLIENT_ID,
|
||||||
@@ -856,12 +856,12 @@ 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:
|
||||||
while True:
|
for delay in ExponentialBackoff(shift=4, maximum=3*60):
|
||||||
async with session.request(method, url, **kwargs) as response:
|
async with session.request(method, url, **kwargs) as response:
|
||||||
logger.debug(f"Response: {response.status}: {response}")
|
logger.debug(f"Response: {response.status}: {response}")
|
||||||
if response.status >= 500:
|
if response.status >= 500:
|
||||||
self.print("Twitter is down, retrying in 120 seconds...")
|
self.print(f"Twitter is down, retrying in {round(delay)} seconds...")
|
||||||
await asyncio.sleep(120)
|
await asyncio.sleep(delay)
|
||||||
continue
|
continue
|
||||||
yield response
|
yield response
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user