mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Added more debugging and perhaps a fix
This commit is contained in:
parent
38b589bf82
commit
2e7dc7edcc
|
@ -48,9 +48,10 @@ class Domain:
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
"""Destroy the domain – do all of the tasks that should make sure there is no leftovers before being collected by GC"""
|
"""Destroy the domain – do all of the tasks that should make sure there is no leftovers before being collected by GC"""
|
||||||
if self.irc:
|
if self.irc:
|
||||||
|
logger.debug("Leaving IRC due to destroy() for domain {}".format(self.name))
|
||||||
self.irc.connection.die("Leaving")
|
self.irc.connection.die("Leaving")
|
||||||
if self.discussions_handler:
|
# if self.discussions_handler:
|
||||||
self.discussions_handler.close()
|
# self.discussions_handler.close()
|
||||||
if self.task:
|
if self.task:
|
||||||
self.task.cancel()
|
self.task.cancel()
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ class DomainManager:
|
||||||
await self.return_domain(self.get_domain(split_payload[1])).get_wiki(split_payload[1]).update_targets()
|
await self.return_domain(self.get_domain(split_payload[1])).get_wiki(split_payload[1]).update_targets()
|
||||||
elif split_payload[0] == "DEBUG":
|
elif split_payload[0] == "DEBUG":
|
||||||
logger.info(self.domains)
|
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:
|
else:
|
||||||
raise ValueError("Unknown pub/sub command! Payload: {}".format(payload))
|
raise ValueError("Unknown pub/sub command! Payload: {}".format(payload))
|
||||||
|
|
||||||
|
@ -60,6 +63,7 @@ class DomainManager:
|
||||||
await new_domain.add_wiki(wiki)
|
await new_domain.add_wiki(wiki)
|
||||||
|
|
||||||
def remove_domain(self, domain: Domain):
|
def remove_domain(self, domain: Domain):
|
||||||
|
logger.debug("Destroying domain and removing it from domain directory")
|
||||||
domain.destroy()
|
domain.destroy()
|
||||||
del self.domains[domain.name]
|
del self.domains[domain.name]
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
||||||
self.connection_details = None
|
self.connection_details = None
|
||||||
|
|
||||||
def on_welcome(self, connection, event): # Join IRC channels
|
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():
|
for channel in self.targets.values():
|
||||||
connection.join(channel)
|
connection.join(channel)
|
||||||
|
|
||||||
|
@ -69,10 +70,10 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
||||||
try:
|
try:
|
||||||
post = json.loads(message)
|
post = json.loads(message)
|
||||||
except json.JSONDecodeError:
|
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
|
return
|
||||||
if post.get('action', 'unknown') != "deleted": # ignore deletion events
|
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
|
return
|
||||||
url = urlparse(post.get('url'))
|
url = urlparse(post.get('url'))
|
||||||
full_url ="https://"+ url.netloc + recognize_langs(url.path)
|
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:
|
if wiki and wiki.discussion_id != -1:
|
||||||
self.updated_discussions.add(full_url)
|
self.updated_discussions.add(full_url)
|
||||||
logger.debug("New discussion wiki appended to the list! {}".format(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):
|
def recognize_langs(path):
|
||||||
|
|
Loading…
Reference in a new issue