Skip to content
Snippets Groups Projects
Commit b0d5622f authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Compute next call of cron task using actual now

If the cron task took more time then the repeating delay, it is not useful to
reschedule it in the past.
parent 71fe3619
No related branches found
No related tags found
1 merge request!1347Improve multiprocessing of cron
......@@ -123,7 +123,9 @@
}),
]
def compute_next_call(self, now):
def compute_next_call(self, now=None):
if now is None:
now = datetime.datetime.now()
return (now.replace(tzinfo=tz.UTC).astimezone(tz.SERVER)
+ relativedelta(**{self.interval_type: self.interval_number})
+ relativedelta(
......@@ -210,7 +212,7 @@
task.lock()
with processing(name):
task.run_once()
task.next_call = task.compute_next_call()
task.next_call = task.compute_next_call(now)
task.save()
logger.info("%s in %i ms", name, duration())
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment