aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-10-02 06:44:21 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-10-02 06:44:21 +0200
commita70cf2070f6af0b7710b0934b7e812dce78330d0 (patch)
tree9bda0654dcbf18fdc6f5c3812b9f2623833c6c08
parentMerge pull request #480 from python-discord/separate_tools_and_resources (diff)
Fix `cog_unload` bug in WatchChannel ABC
https://github.com/python-discord/bot/issues/482 There was small bug in the `cog_unload` method of the WatchChannel ABC in `bot.cogs.watchchannels.watchchannel`. The problem was that it tries to check if the Task assigned to `self._consume_task` is done by accessing its `done` method. However, if a watch channel has not yet relayed messages after the bot has started, it will not have a consumption task yet, meaning this `_consume_task` attribute will be assigned to `None`. The solution is to change the `if` condition to: `if self._consume_task and not self._consume_task.done():` This commit closes #482
-rw-r--r--bot/cogs/watchchannels/watchchannel.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/bot/cogs/watchchannels/watchchannel.py b/bot/cogs/watchchannels/watchchannel.py
index ce8014d69..760e012eb 100644
--- a/bot/cogs/watchchannels/watchchannel.py
+++ b/bot/cogs/watchchannels/watchchannel.py
@@ -335,7 +335,7 @@ class WatchChannel(metaclass=CogABCMeta):
def cog_unload(self) -> None:
"""Takes care of unloading the cog and canceling the consumption task."""
self.log.trace(f"Unloading the cog")
- if not self._consume_task.done():
+ if self._consume_task and not self._consume_task.done():
self._consume_task.cancel()
try:
self._consume_task.result()