aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-25 21:20:20 -0800
committerGravatar MarkKoz <[email protected]>2020-02-25 21:59:09 -0800
commitb1f8f4779738be35e1339d6c07e317ef08009467 (patch)
treef8c988c55cb8dbabbafdb236f00636e7e4095584
parentModeration: use asyncio.shield to prevent self-cancellation (diff)
Scheduler: improve cancel_task's docstring
* Use imperative mood for docstring * Explain the purpose of the parameter in the docstring * Make log message after cog name lowercase
-rw-r--r--bot/utils/scheduling.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bot/utils/scheduling.py b/bot/utils/scheduling.py
index 0d66952eb..cb28648db 100644
--- a/bot/utils/scheduling.py
+++ b/bot/utils/scheduling.py
@@ -52,19 +52,19 @@ class Scheduler(metaclass=CogABCMeta):
log.debug(f"{self.cog_name}: scheduled task #{task_id} {id(task)}.")
def cancel_task(self, task_id: str) -> None:
- """Un-schedules a task."""
+ """Unschedule the task identified by `task_id`."""
log.trace(f"{self.cog_name}: cancelling task #{task_id}...")
-
task = self._scheduled_tasks.get(task_id)
- if task is None:
- log.warning(f"{self.cog_name}: Failed to unschedule {task_id} (no task found).")
+ if not task:
+ log.warning(f"{self.cog_name}: failed to unschedule {task_id} (no task found).")
return
task.cancel()
- log.debug(f"{self.cog_name}: unscheduled task #{task_id} {id(task)}.")
del self._scheduled_tasks[task_id]
+ log.debug(f"{self.cog_name}: unscheduled task #{task_id} {id(task)}.")
+
def _task_done_callback(self, task_id: str, task: asyncio.Task) -> None:
"""
Unschedule the task and raise its exception if one exists.