Fixed exception on debug dump for cancelled tasks

This commit is contained in:
Frisk 2024-09-10 10:06:56 +02:00
parent 44250a4200
commit fab76d7355

View file

@ -53,7 +53,10 @@ class DomainManager:
return (payload[0 + i:length + i] for i in range(0, len(payload), length))
async def webhook_update(self, connection: asyncpg.Connection, pid: int, channel: str, payload: str):
def result_handler(result):
def result_handler(result: asyncio.Task):
if result.cancelled():
return "cancelled"
result = result.result()
if result is None:
return None
if isinstance(result, Exception):
@ -116,7 +119,7 @@ class DomainManager:
}
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}
json_object["tasks"][task_name] = {"done": task.done(), "result": result_handler(task) if task.done() else None}
for name, domain in self.domains.items():
json_object["domains"][name] = domain.json()
for message in messagequeue._queue: