mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-22 00:44:10 +00:00
Made it compatible with older Python versions
This commit is contained in:
parent
fd5ae05740
commit
76b19f03b3
27
src/wiki.py
27
src/wiki.py
|
@ -487,20 +487,19 @@ class Wiki:
|
||||||
self.client.last_request = request
|
self.client.last_request = request
|
||||||
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError, WikiServerError, ServerError) as e:
|
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError, WikiServerError, ServerError) as e:
|
||||||
self.statistics.update(Log(type=LogType.CONNECTION_ERROR, title=str(e.exception)))
|
self.statistics.update(Log(type=LogType.CONNECTION_ERROR, title=str(e.exception)))
|
||||||
match len(self.statistics.last_connection_failures()[0]):
|
amount_of_failures = len(self.statistics.last_connection_failures()[0])
|
||||||
case 0, 1:
|
if amount_of_failures < 2:
|
||||||
await asyncio.sleep(5.0)
|
await asyncio.sleep(5.0)
|
||||||
continue
|
continue
|
||||||
case 2: # Put the wiki on timeout 5 minutes per each
|
elif amount_of_failures == 2: # Put the wiki on timeout 5 minutes per each
|
||||||
self.put_wiki_on_timeout(timedelta(minutes=5))
|
self.put_wiki_on_timeout(timedelta(minutes=5))
|
||||||
raise WikiOnTimeout(self.dont_fetch_before)
|
raise WikiOnTimeout(self.dont_fetch_before)
|
||||||
case _:
|
else:
|
||||||
x = len(self.statistics.last_connection_failures()[0])
|
self.put_wiki_on_timeout(timedelta(seconds=min(21600, int(math.sqrt(2*amount_of_failures)*(amount_of_failures/0.4))*60))) # Max backoff is 6 hours
|
||||||
self.put_wiki_on_timeout(timedelta(seconds=min(21600, int(math.sqrt(2*x)*(x/0.4))*60))) # Max backoff is 6 hours
|
if amount_of_failures > 30 and self.domain.last_failure_report < (time.time() - 21600): # Report only if domain didn't report something within last 6 hours
|
||||||
if x > 30 and self.domain.last_failure_report < (time.time() - 21600): # Report only if domain didn't report something within last 6 hours
|
await send_unique_generic_to_monitoring(self.script_url + "?CONNERROR",
|
||||||
await send_unique_generic_to_monitoring(self.script_url + "?CONNERROR",
|
f"{self.script_url} errors", repr(e))
|
||||||
f"{self.script_url} errors", repr(e))
|
raise WikiOnTimeout(self.dont_fetch_before)
|
||||||
raise WikiOnTimeout(self.dont_fetch_before)
|
|
||||||
|
|
||||||
except ServerRedirects as e:
|
except ServerRedirects as e:
|
||||||
self.statistics.update(Log(type=LogType.REDIRECT, title=""))
|
self.statistics.update(Log(type=LogType.REDIRECT, title=""))
|
||||||
|
|
Loading…
Reference in a new issue