fix(pterodactyl): fixed exceptions in the websocket task being suppressed

This commit is contained in:
Seaswimmer 2024-02-29 21:35:09 -05:00
parent 366bafcd27
commit 0aa17e8807
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -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()