mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fixed some improper debug responses
This commit is contained in:
parent
9fd1cc9904
commit
409678b2cb
|
@ -105,7 +105,7 @@ class MessageQueue:
|
|||
logger.error("MessageQueue.suspension_check failed due to lack of messages belonging to a webhook ID {} in message queue".format(webhook_url.split("/")[0]))
|
||||
return
|
||||
logger.debug("Attempting to send messages for the suspended webhook.")
|
||||
await self.send_msg_set(webhook_messages)
|
||||
await self.send_msg_set((webhook_url, webhook_messages,))
|
||||
|
||||
@staticmethod
|
||||
def compare_message_to_dict(metadata: DiscordMessageMetadata, to_match: dict):
|
||||
|
|
|
@ -36,6 +36,18 @@ class DomainManager:
|
|||
def __init__(self):
|
||||
self.domains: dict[str, Domain] = {}
|
||||
self.start_time: float = time.time()
|
||||
self.task_store: dict[str, asyncio.Task] = {}
|
||||
asyncio.create_task(self.task_tracker(), name="TaskTracer")
|
||||
|
||||
async def task_tracker(self, one_update=False):
|
||||
"""Task tracer is supposed to keep track of all tasks spawned for /debug endpoint to show them.
|
||||
It replaces asyncio.all_tasks() in order to show even tasks that have finished running."""
|
||||
while 1:
|
||||
for task in asyncio.all_tasks():
|
||||
self.task_store[task.get_name()] = task
|
||||
if one_update:
|
||||
return
|
||||
await asyncio.sleep(3600.0)
|
||||
|
||||
@staticmethod
|
||||
def chunkstring(payload, length):
|
||||
|
@ -102,8 +114,9 @@ class DomainManager:
|
|||
"awaiting_DB_queries": dbmanager.json(),
|
||||
"total_discord_messages_sent": sum([x.total_discord_messages_sent for x in self.domains.values()])
|
||||
}
|
||||
for task in asyncio.all_tasks():
|
||||
json_object["tasks"][task.get_name()] = {"done": task.done(), "result": result_handler(task.result()) if task.done() else None}
|
||||
await self.task_tracker(one_update=True)
|
||||
for task_name, task in self.task_store.items():
|
||||
json_object["tasks"][task_name] = {"done": task.done(), "result": result_handler(task.result()) if task.done() else None}
|
||||
for name, domain in self.domains.items():
|
||||
json_object["domains"][name] = domain.json()
|
||||
for message in messagequeue._queue:
|
||||
|
@ -130,7 +143,7 @@ class DomainManager:
|
|||
wiki_json["wiki_rc"] = await wiki.api_request(params=params, timeout=5)
|
||||
except:
|
||||
wiki_json["wiki_rc"] = None
|
||||
json_string: str = json.dumps(wiki.json())
|
||||
json_string: str = json.dumps(wiki_json)
|
||||
for json_part in self.chunkstring(json_string, 7950):
|
||||
await connection.execute("select pg_notify('debugresponse', 'SITE CHUNK ' || $1 || ' ' || $2);",
|
||||
req_id, json_part)
|
||||
|
|
Loading…
Reference in a new issue