From 0aa17e88075b3911806953e7076bf6a2cdc914a1 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 29 Feb 2024 21:35:09 -0500 Subject: [PATCH] fix(pterodactyl): fixed exceptions in the websocket task being suppressed --- pterodactyl/pterodactyl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.py b/pterodactyl/pterodactyl.py index a20b4d1..4b53973 100644 --- a/pterodactyl/pterodactyl.py +++ b/pterodactyl/pterodactyl.py @@ -1,3 +1,4 @@ +import asyncio import json import logging import re @@ -160,7 +161,17 @@ class Pterodactyl(commands.Cog): return tellraw def get_task(self): - return self.bot.loop.create_task(self.establish_websocket_connection(), name="Pterodactyl Websocket Connection") + task = self.bot.loop.create_task(self.establish_websocket_connection(), name="Pterodactyl Websocket Connection") + task.add_done_callback(self.error_callback) + return task + + def error_callback(self, fut): #NOTE - Thanks flame442 and zephyrkul for helping me figure this out + try: + fut.result() + except asyncio.CancelledError: + pass + except Exception as e: + self.logger.error("WebSocket task has failed: %s", e, exc_info=e) async def cog_load(self): self.task = self.get_task()