'How to get status of job using Scheduler?

I have a scheduled job running on Scheduler library, and I would like to get its status ("Success", "Failed") from python but I can't find documentation on how to get the status.

Let's take as an example the following code to use the scheduler :

import datetime as dt
import time

from scheduler import Scheduler

import scheduler.trigger as trigger

def foo():

    print("foo")

schedule = Scheduler()
schedule.minutely(dt.time(second=15), foo)
while True:  

    schedule.exec_jobs()

    time.sleep(1)

I can only print the scheduler but I need to print the status of execution, is it possible ?

>>> print(schedule)  
max_exec=inf, tzinfo=None, priority_function=linear_priority_function, #jobs=9

type     function         due at                 due in      attempts weight
-------- ---------------- ------------------- --------- ------------- ------
MINUTELY foo(..)          2022-03-30 00:37:15   0:00:14         0/inf      1

Please advise



Solution 1:[1]

The job itself has no status message like ("Success", "Failed") because the job does not know if the logic in the scheduled function was "successful". The user must therefore program the logic himself whether the execution has proceeded as desired. If you want to know if the job was executed at all, regardless of the result, you can look at the number of executions. The job has the properties attempts, max_attempts and has_attempts_remaining for this purpose. Here you can find the doc page. Maybe this example can help you too.

Disclosure: I am one of the authors of the library.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jpotyka