【发布时间】:2023-01-10 06:59:58
【问题描述】:
我有一个在 Scheduler 库上运行的预定作业,我想从 python 获取它的状态 ("Success", "Failed") 但我找不到关于如何获取状态的文档。
让我们以下面的代码为例来使用调度程序:
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)
我只能打印调度程序,但我需要打印执行状态,这可能吗?
>>> 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
请指教
【问题讨论】:
-
如果您认为此功能缺失,如果您在 GitLab 上的project page 上打开一个问题,我将很高兴。
-
@jpotyka 当然可以,谢谢!另外,如果可能的话,我想借此机会询问库中的另一个功能。是否有可能获得已执行作业的最后日期时间?我可以在您提供的文档中找到
datetime,这是为了获取计划执行的日期时间对象,但我想知道是否有一个用于过去执行作业的日期时间对象?谢谢