Retrieving failed jobs

37 views
Skip to first unread message

José Ignacio Flores Belmares

unread,
Jan 15, 2021, 1:26:55 PM1/15/21
to APScheduler
How can I get the jobs that have failed and know if the scheduler is going to trigger them again.

I want to have something similar to this but with failed jobs:

MODEL
class CurrentScheduledJob(BaseModel):
job_id:str=Field(title="The Job ID in APScheduler",description="The Job ID in APScheduler")
run_frequency:str=Field(title="The Job Interval in APScheduler",description="The Job Interval in APScheduler")
next_run:str=Field(title="Next Scheduled Run for the Job",description="Next Scheduled Run for the Job")
class Config:
schema_extra = {
'example': {
"job_id": "www.google.com",
"run_frequency": "interval[0:05:00]",
"next_run": "2021-01-14 22:12:09.397935+10:00"
}
}

ENDPOINT
@app.get("/schedule/show_schedules/",response_model=CurrentScheduledJobsResponse,tags=["schedule"])
async def get_scheduled_syncs():
"""
Will provide a list of currently Scheduled Tasks

"""
schedules = []
for job in Schedule.get_jobs():
schedules.append({"job_id": str(job.id), "run_frequency": str(job.trigger), "next_run": str(job.next_run_time)})
return {"jobs":schedules}
Reply all
Reply to author
Forward
0 new messages