fix: handle cold start edge case
This commit is contained in:
parent
a8452484a0
commit
d4c49a70c2
1 changed files with 6 additions and 3 deletions
|
|
@ -105,9 +105,12 @@ class ScheduledJobType(Document):
|
|||
if not self.cron_format:
|
||||
self.cron_format = CRON_MAP[self.frequency]
|
||||
|
||||
return croniter(
|
||||
self.cron_format, get_datetime(self.last_execution or now_datetime())
|
||||
).get_next(datetime)
|
||||
# If this is a cold start then last_execution will not be set.
|
||||
# Creation is set as fallback because if very old fallback is set job might trigger
|
||||
# immediately, even when it's meant to be daily.
|
||||
# A dynamic fallback like current time might miss the scheduler interval and job will never start.
|
||||
last_execution = get_datetime(self.last_execution or self.creation)
|
||||
return croniter(self.cron_format, last_execution).get_next(datetime)
|
||||
|
||||
def execute(self):
|
||||
self.scheduler_log = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue