diff options
| author | 2021-01-09 21:59:03 +0100 | |
|---|---|---|
| committer | 2021-01-10 06:16:10 +0100 | |
| commit | 5ad2afbc0160a7d9b0ab9c50b73044e7169db7cb (patch) | |
| tree | 5c6234589afe9767c521a9562cb29e1df92f05b0 | |
| parent | Periodically clear unnecessary futures from the _item_futures dict (diff) | |
Stop scheduled and long running tasks on cog unload
| -rw-r--r-- | bot/exts/info/doc/_cog.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 364d99182..61ac35b6f 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -567,3 +567,9 @@ class DocCog(commands.Cog): await ctx.send(f"Successfully cleared the cache for `{package_name}`.") else: await ctx.send("No keys matching the package found.") + + def cog_unload(self) -> None: + """Clear scheduled inventories, queued symbols and cleanup task on cog unload.""" + self.inventory_scheduler.cancel_all() + self.item_fetcher.cleanup_futures_task.cancel() + asyncio.create_task(self.item_fetcher.clear()) |