From 5ecb8dc826f40f62222c7ccb0b22fe46dcfbcc16 Mon Sep 17 00:00:00 2001 From: bobloy Date: Wed, 25 Nov 2020 10:14:09 -0500 Subject: [PATCH] Don't schedule jobs without a trigger --- fifo/fifo.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fifo/fifo.py b/fifo/fifo.py index 9f3bb47..8ff9c80 100644 --- a/fifo/fifo.py +++ b/fifo/fifo.py @@ -148,7 +148,11 @@ class FIFO(commands.Cog): async def _process_task(self, task: Task): job: Union[Job, None] = await self._get_job(task) if job is not None: - job.reschedule(await task.get_combined_trigger()) + combined_trigger_ = await task.get_combined_trigger() + if combined_trigger_ is None: + job.remove() + else: + job.reschedule(combined_trigger_) return job return await self._add_job(task) @@ -156,11 +160,15 @@ class FIFO(commands.Cog): return self.scheduler.get_job(_assemble_job_id(task.name, task.guild_id)) async def _add_job(self, task: Task): + combined_trigger_ = await task.get_combined_trigger() + if combined_trigger_ is None: + return None + return self.scheduler.add_job( _execute_task, kwargs=task.__getstate__(), id=_assemble_job_id(task.name, task.guild_id), - trigger=await task.get_combined_trigger(), + trigger=combined_trigger_, name=task.name, )