aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-06-19 22:49:41 -0700
committerGravatar MarkKoz <[email protected]>2020-06-19 22:49:41 -0700
commit5130611719735d8e58c1d0faeeeaffe4553843dd (patch)
treead0a5831f2b897c70813b5bdde29e950b38f8cff
parentScheduler: name tasks (diff)
Scheduler: add support for in operator
-rw-r--r--bot/utils/scheduling.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bot/utils/scheduling.py b/bot/utils/scheduling.py
index f2640ed5e..00fca4169 100644
--- a/bot/utils/scheduling.py
+++ b/bot/utils/scheduling.py
@@ -14,6 +14,10 @@ class Scheduler:
self._log = logging.getLogger(f"{__name__}.{name}")
self._scheduled_tasks: t.Dict[t.Hashable, asyncio.Task] = {}
+ def __contains__(self, task_id: t.Hashable) -> bool:
+ """Return True if a task with the given `task_id` is currently scheduled."""
+ return task_id in self._scheduled_tasks
+
def schedule_task(self, task_id: t.Hashable, task: t.Awaitable) -> None:
"""Schedule the execution of a task."""
self._log.trace(f"Scheduling task #{task_id}...")