From 4d7d29aef45d78a648deba4554d70eeff9691a4c Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Mon, 24 Feb 2020 12:25:29 -0800 Subject: HelpChannels: cancel the init task when unloading the cog This will prevent initialisation from proceeding when the category channels fail to be retrieved. --- bot/cogs/help_channels.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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.""" -- cgit v1.2.3