mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fixes to premature exiting from tasks for regular schedulers, improvements to debugging interface
This commit is contained in:
parent
c4a3a41c5f
commit
2afa405395
|
@ -127,7 +127,7 @@ class Domain:
|
|||
self.failures += 1
|
||||
traceback.print_exc()
|
||||
await self.send_exception_to_monitoring(e)
|
||||
if self.failures > 2:
|
||||
if self.failures > 5:
|
||||
raise asyncio.exceptions.CancelledError
|
||||
|
||||
async def regular_scheduler(self):
|
||||
|
@ -139,9 +139,10 @@ class Domain:
|
|||
if command_line_args.debug:
|
||||
logger.exception("Regular scheduler task for domain {} failed!".format(self.name))
|
||||
else:
|
||||
await self.send_exception_to_monitoring(e)
|
||||
self.failures += 1
|
||||
if self.failures > 2:
|
||||
await self.send_exception_to_monitoring(e)
|
||||
traceback.print_exc()
|
||||
if self.failures > 5:
|
||||
raise asyncio.exceptions.CancelledError
|
||||
|
||||
@cache
|
||||
|
@ -159,12 +160,15 @@ class Domain:
|
|||
for wiki in self.wikis.values():
|
||||
await wiki.session.close()
|
||||
self.irc.connection.disconnect()
|
||||
raise
|
||||
else:
|
||||
try:
|
||||
await self.regular_scheduler()
|
||||
while True:
|
||||
await self.regular_scheduler()
|
||||
except asyncio.exceptions.CancelledError:
|
||||
for wiki in self.wikis.values():
|
||||
await wiki.session.close()
|
||||
raise
|
||||
|
||||
async def send_exception_to_monitoring(self, ex: Exception):
|
||||
discord_message = DiscordMessage("embed", "generic", [""])
|
||||
|
|
|
@ -8,7 +8,8 @@ from src.exceptions import NoDomain
|
|||
from src.config import settings
|
||||
from src.domain import Domain
|
||||
from src.irc_feed import AioIRCCat
|
||||
|
||||
from io import StringIO
|
||||
from contextlib import redirect_stdout
|
||||
from src.wiki import Wiki
|
||||
|
||||
logger = logging.getLogger("rcgcdb.domain_manager")
|
||||
|
@ -57,11 +58,14 @@ class DomainManager:
|
|||
if self.check_for_domain(self.get_domain(split_payload[1])):
|
||||
logger.info(str(self.return_domain(self.get_domain(split_payload[1])).get_wiki(split_payload[1])))
|
||||
elif split_payload[1] == "EXEC":
|
||||
logger.debug(exec(" ".join(split_payload[2:])))
|
||||
f = StringIO()
|
||||
with redirect_stdout(f):
|
||||
exec(" ".join(split_payload[2:]))
|
||||
logger.info(f.getvalue())
|
||||
elif split_payload[1] == "WIKI" and len(split_payload) > 2:
|
||||
domain = self.return_domain(self.get_domain(split_payload[2]))
|
||||
logger.debug("RCGCDBDEBUG Domain information for {}: {}".format(domain.name, str(domain)))
|
||||
logger.debug("RCGCDBDEBUG Wiki information for {}: {}".format(split_payload[2], domain.get_wiki(split_payload[2])))
|
||||
logger.info("RCGCDBDEBUG Domain information for {}: {}".format(domain.name, str(domain)))
|
||||
logger.info("RCGCDBDEBUG Wiki information for {}: {}".format(split_payload[2], domain.get_wiki(split_payload[2])))
|
||||
else:
|
||||
raise ValueError("Unknown pub/sub command! Payload: {}".format(payload))
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ class Wiki:
|
|||
except WikiServerError as e:
|
||||
# If WikiServerError comes up 2 times in recent 2 minutes, this will reraise the exception, otherwise waits 2 seconds and retries
|
||||
self.statistics.update(Log(type=LogType.CONNECTION_ERROR, title=str(e.exception)))
|
||||
if self.statistics.recent_connection_errors() > 1:
|
||||
if self.statistics.recent_connection_errors() > 9:
|
||||
raise
|
||||
await asyncio.sleep(2.0)
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue