1 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個贊
嘗試使用裝飾器方法。它應(yīng)該有效。
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
scheduler = BackgroundScheduler()
scheduler.start()
@scheduler.scheduled_job(IntervalTrigger(seconds=60))
def func_to_be_executed():
pass
BlockingSchedular 的代碼 - 當(dāng)調(diào)度程序是進(jìn)程中唯一運(yùn)行的東西時使用
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.interval import IntervalTrigger
sched = BlockingScheduler()
@sched.scheduled_job(IntervalTrigger(seconds=10))
def timed_job():
print('This job is run every 10 seconds.')
sched.start()
添加回答
舉報