Added more debugging and perhaps a fix

This commit is contained in:
Frisk 2023-08-14 17:03:03 +02:00
parent 38b589bf82
commit 2e7dc7edcc
3 changed files with 10 additions and 6 deletions

View file

@ -48,9 +48,10 @@ class Domain:
def destroy(self):
"""Destroy the domain do all of the tasks that should make sure there is no leftovers before being collected by GC"""
if self.irc:
logger.debug("Leaving IRC due to destroy() for domain {}".format(self.name))
self.irc.connection.die("Leaving")
if self.discussions_handler:
self.discussions_handler.close()
# if self.discussions_handler:
# self.discussions_handler.close()
if self.task:
self.task.cancel()

View file

@ -45,6 +45,9 @@ class DomainManager:
await self.return_domain(self.get_domain(split_payload[1])).get_wiki(split_payload[1]).update_targets()
elif split_payload[0] == "DEBUG":
logger.info(self.domains)
for name, domain in self.domains.items():
logger.info("{name} - Status: {status}, exception: {exception}".format(name=name, status=domain.task.done(),
exception=domain.task.get_stack()))
else:
raise ValueError("Unknown pub/sub command! Payload: {}".format(payload))
@ -60,6 +63,7 @@ class DomainManager:
await new_domain.add_wiki(wiki)
def remove_domain(self, domain: Domain):
logger.debug("Destroying domain and removing it from domain directory")
domain.destroy()
del self.domains[domain.name]

View file

@ -33,6 +33,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
self.connection_details = None
def on_welcome(self, connection, event): # Join IRC channels
logger.debug("Logged into IRC for {domain_name}".format(domain_name=self.domain.name))
for channel in self.targets.values():
connection.join(channel)
@ -69,10 +70,10 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
try:
post = json.loads(message)
except json.JSONDecodeError:
logger.warning("Seems like we have invalid JSON in Discussions part, message: {}".format(message))
#logger.warning("Seems like we have invalid JSON in Discussions part, message: {}".format(message))
return
if post.get('action', 'unknown') != "deleted": # ignore deletion events
if isinstance(post.get('url'), bytes):
if isinstance(post.get('url'), bytes) or post.get('url') == "":
return
url = urlparse(post.get('url'))
full_url ="https://"+ url.netloc + recognize_langs(url.path)
@ -80,8 +81,6 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
if wiki and wiki.discussion_id != -1:
self.updated_discussions.add(full_url)
logger.debug("New discussion wiki appended to the list! {}".format(full_url))
# if full_url in self.domain:
# self.discussion_callback(full_url)
def recognize_langs(path):