Added some basic connection problems handling

This commit is contained in:
DevilXD committed 2022-01-22 21:10:12 +01:00
1 parent 0227362537
commit 59cceaf474
2 files changed
+35 -16

No files matched your search

+11 -2
View File
@@ -9,6 +9,8 @@ from functools import cached_property
from datetime import datetime, timezone
from typing import Any, Optional, SupportsInt, TYPE_CHECKING
import aiohttp
from exceptions import MinerException
from utils import Game, invalidate_cache
from constants import JsonType, BASE_URL, GQL_OPERATIONS, ONLINE_DELAY, DROPS_ENABLED_TAG
@@ -304,5 +306,12 @@ class Channel:
if self._spade_url is None:
self._spade_url = await self.get_spade_url()
logger.debug(f"Sending minute-watched to {self.name}")
async with self._twitch._session.post(self._spade_url, data=self._payload) as response:
return response.status == 204
for attempt in range(5):
try:
async with self._twitch._session.post(
self._spade_url, data=self._payload
) as response:
return response.status == 204
except (aiohttp.ClientConnectionError, aiohttp.ServerTimeoutError):
continue
return False