aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-06-20 13:23:50 -0700
committerGravatar MarkKoz <[email protected]>2020-06-20 13:23:50 -0700
commitee47b2afda1f8f409c1c60bd874d15b1d1a52ca6 (patch)
tree8d23a1714a39408b801c00c5e75d00142b0d0b15
parentScheduler: 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.py6
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