diff options
| author | 2020-06-20 13:23:50 -0700 | |
|---|---|---|
| committer | 2020-06-20 13:23:50 -0700 | |
| commit | ee47b2afda1f8f409c1c60bd874d15b1d1a52ca6 (patch) | |
| tree | 8d23a1714a39408b801c00c5e75d00142b0d0b15 | |
| parent | Scheduler: drop _task suffix from method names (diff) | |
Scheduler: rename "task" param to "coroutine"
Naming it "task" is inaccurate because `create_task` accepts a coroutine
rather than a Task. What it does is wrap the coroutine in a Task.
| -rw-r--r-- | bot/utils/scheduling.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/utils/scheduling.py b/bot/utils/scheduling.py index 4a003d4fe..625b726d2 100644 --- a/bot/utils/scheduling.py +++ b/bot/utils/scheduling.py @@ -18,15 +18,15 @@ class Scheduler: """Return True if a task with the given `task_id` is currently scheduled.""" return task_id in self._scheduled_tasks - def schedule(self, task_id: t.Hashable, task: t.Awaitable) -> None: - """Schedule the execution of a task.""" + def schedule(self, task_id: t.Hashable, coroutine: t.Coroutine) -> None: + """Schedule the execution of a coroutine.""" self._log.trace(f"Scheduling task #{task_id}...") if task_id in self._scheduled_tasks: self._log.debug(f"Did not schedule task #{task_id}; task was already scheduled.") return - task = asyncio.create_task(task, name=f"{self.name}_{task_id}") + task = asyncio.create_task(coroutine, name=f"{self.name}_{task_id}") task.add_done_callback(partial(self._task_done_callback, task_id)) self._scheduled_tasks[task_id] = task |