diff options
| author | 2020-11-26 14:07:29 -0800 | |
|---|---|---|
| committer | 2020-11-26 14:07:29 -0800 | |
| commit | d9f87cc867a93d5f2d14d16eaac86ccb5adef447 (patch) | |
| tree | b0a155073120368738731325cc34984371484f1b | |
| parent | Help channels: remove how_to_get_help from excluded channels (diff) | |
Help channels: don't check if task is done before awaiting
Awaiting a done task is effectively a no-op, so it's redundant to check
if the task is done before awaiting it.
Furthermore, a task is also considered done if it was cancelled or an
exception was raised. Therefore, avoiding awaiting in such cases doesn't
allow the errors to be propagated and incorrectly allows the awaiter to
keep executing.
| -rw-r--r-- | bot/exts/help_channels/_cog.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 638d00e4a..e22d4663e 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -426,9 +426,8 @@ class HelpChannels(commands.Cog): if not is_available or _channel.is_excluded_channel(channel): return # Ignore messages outside the Available category or in excluded channels. - if not self.init_task.done(): - log.trace("Waiting for the cog to be ready before processing messages.") - await self.init_task + log.trace("Waiting for the cog to be ready before processing messages.") + await self.init_task log.trace("Acquiring lock to prevent a channel from being processed twice...") async with self.on_message_lock: @@ -478,9 +477,8 @@ class HelpChannels(commands.Cog): if not await _message.is_empty(msg.channel): return - if not self.init_task.done(): - log.trace("Waiting for the cog to be ready before processing deleted messages.") - await self.init_task + log.trace("Waiting for the cog to be ready before processing deleted messages.") + await self.init_task log.info(f"Claimant of #{msg.channel} ({msg.author}) deleted message, channel is empty now. Rescheduling task.") |