diff --git a/src/domain.py b/src/domain.py index ee50fbb..7445d82 100644 --- a/src/domain.py +++ b/src/domain.py @@ -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() diff --git a/src/domain_manager.py b/src/domain_manager.py index 7926275..11537fa 100644 --- a/src/domain_manager.py +++ b/src/domain_manager.py @@ -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] diff --git a/src/irc_feed.py b/src/irc_feed.py index 242a2a1..7e4cc77 100644 --- a/src/irc_feed.py +++ b/src/irc_feed.py @@ -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):