我正在研究一个烧瓶应用程序,它使用
BackgroundScheduler
. 应用程序的一个功能是发送一个请求,该请求在特定日期安排作业,但前提是该日期还没有作业。所以我想我可以依靠这份工作
id
下面是一个超级简单的例子
身份证件
调度程序:
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
def hello():
print "Hello!"
def goodbye():
print "Goodbye!"
scheduler.add_job(hello, trigger='interval', seconds=5, id='1')
scheduler.add_job(goodbye, trigger='interval', seconds=5, id='1')
print scheduler.get_jobs()
print scheduler.get_job('1')
[<Job (id=1 name=hello)>, <Job (id=1 name=goodbye)>]
hello (trigger: interval[0:00:05], pending)
我本以为这会因为ID冲突而出错。但是,这两个作业都已注册,在查询特定作业ID时,只返回第一个作业。
另外,设置
replace_existing
参数到
True
我是否遗漏了一些重要的东西,比如配置job store?