fix(pterodactyl): fixed exceptions in the websocket task being suppressed
This commit is contained in:
parent
366bafcd27
commit
0aa17e8807
1 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
@ -160,7 +161,17 @@ class Pterodactyl(commands.Cog):
|
||||||
return tellraw
|
return tellraw
|
||||||
|
|
||||||
def get_task(self):
|
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):
|
async def cog_load(self):
|
||||||
self.task = self.get_task()
|
self.task = self.get_task()
|
||||||
|
|
Loading…
Reference in a new issue