aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-24 12:25:29 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:34 -0700
commit4d7d29aef45d78a648deba4554d70eeff9691a4c (patch)
tree004614bacb1bda65f9bbc44e924ef76b731d3c6b
parentHelpChannels: add a function to initialise the cog (diff)
HelpChannels: cancel the init task when unloading the cog
This will prevent initialisation from proceeding when the category channels fail to be retrieved.
-rw-r--r--bot/cogs/help_channels.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 1e99f16b5..3865183b0 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -56,7 +56,11 @@ class HelpChannels(Scheduler, commands.Cog):
self.channel_queue: asyncio.Queue = None
self.name_queue: deque = None
- asyncio.create_task(self.init_cog())
+ self.init_task = asyncio.create_task(self.init_cog())
+
+ async def cog_unload(self) -> None:
+ """Cancel the init task if the cog unloads."""
+ self.init_task.cancel()
async def create_channel_queue(self) -> asyncio.Queue:
"""Return a queue of dormant channels to use for getting the next available channel."""