Account for the request invalidation happening during the request
This commit is contained in:
1 parent
8069168873
commit
1810d802b4
1 file changed
+8
-1
@@ -974,10 +974,17 @@ class Twitch:
|
|||||||
if self.settings.proxy and "proxy" not in kwargs:
|
if self.settings.proxy and "proxy" not in kwargs:
|
||||||
kwargs["proxy"] = self.settings.proxy
|
kwargs["proxy"] = self.settings.proxy
|
||||||
logger.debug(f"Request: ({method=}, {url=}, {kwargs=})")
|
logger.debug(f"Request: ({method=}, {url=}, {kwargs=})")
|
||||||
|
session_timeout = timedelta(
|
||||||
|
seconds=cast(aiohttp.ClientTimeout, session.timeout).total or 0
|
||||||
|
)
|
||||||
for delay in ExponentialBackoff(maximum=3*60):
|
for delay in ExponentialBackoff(maximum=3*60):
|
||||||
if self.gui.close_requested:
|
if self.gui.close_requested:
|
||||||
raise ExitRequest()
|
raise ExitRequest()
|
||||||
elif invalidate_after is not None and datetime.now(timezone.utc) >= invalidate_after:
|
elif (
|
||||||
|
invalidate_after is not None
|
||||||
|
# account for the expiration landing during the request
|
||||||
|
and datetime.now(timezone.utc) >= (invalidate_after - session_timeout)
|
||||||
|
):
|
||||||
raise ReloadRequest()
|
raise ReloadRequest()
|
||||||
try:
|
try:
|
||||||
response: aiohttp.ClientResponse | None = None
|
response: aiohttp.ClientResponse | None = None
|
||||||
|
|||||||
Reference in new issue
Block a user