fix: Dont let one invalid cron fail scheduler
Scenario: - One bad cron job exists - When it fails nothing after that job is enqueued. After this fix, that failure is skipped and rest of the jobs are enqueued.
This commit is contained in:
parent
0a34f8b28e
commit
b0aaeb5096
2 changed files with 9 additions and 3 deletions
|
|
@ -115,7 +115,7 @@ class ScheduledJobType(Document):
|
|||
}
|
||||
|
||||
if not self.cron_format:
|
||||
self.cron_format = CRON_MAP[self.frequency]
|
||||
self.cron_format = CRON_MAP.get(self.frequency)
|
||||
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import time
|
|||
from typing import NoReturn
|
||||
|
||||
import setproctitle
|
||||
from croniter import CroniterBadCronError
|
||||
|
||||
# imports - module imports
|
||||
import frappe
|
||||
|
|
@ -100,8 +101,13 @@ def enqueue_events() -> list[str] | None:
|
|||
enqueued_jobs = []
|
||||
for job_type in frappe.get_all("Scheduled Job Type", filters={"stopped": 0}, fields="*"):
|
||||
job_type = frappe.get_doc(doctype="Scheduled Job Type", **job_type)
|
||||
if job_type.enqueue():
|
||||
enqueued_jobs.append(job_type.method)
|
||||
try:
|
||||
if job_type.enqueue():
|
||||
enqueued_jobs.append(job_type.method)
|
||||
except CroniterBadCronError:
|
||||
frappe.logger("scheduler").error(
|
||||
f"Invalid Job on {frappe.local.site} - {job_type.name}", exc_info=True
|
||||
)
|
||||
|
||||
return enqueued_jobs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue