Python 定时任务框架 APScheduler
生活随笔
收集整理的這篇文章主要介紹了
Python 定时任务框架 APScheduler
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?Python定時任務:多種實現方法
Python 定時任務框架 APScheduler 詳解
APScheduler官方文檔
Git-hub examples
例子1:apscheduler.triggers.interval:以固定的時間間隔運行 job
""" Demonstrates how to schedule a job to be run in a process pool on 3 second intervals. """from datetime import datetime import osfrom apscheduler.schedulers.blocking import BlockingSchedulerdef tick():print('Tick! The time is: %s' % datetime.now())if __name__ == '__main__':scheduler = BlockingScheduler()scheduler.add_executor('processpool')scheduler.add_job(tick, 'interval', seconds=3)print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))try:scheduler.start()except (KeyboardInterrupt, SystemExit):pass例子2:apscheduler.triggers.date:在某個特定時間僅運行一次 job
from datetime import datetime from apscheduler.schedulers.blocking import BlockingSchedulerdef tick():print('Tick! The time is: %s' % datetime.now())if __name__ == '__main__':scheduler = BlockingScheduler()scheduler.add_job(task, 'date', run_date='2020-7-20 12:03:01')scheduler.start()?
?
總結
以上是生活随笔為你收集整理的Python 定时任务框架 APScheduler的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 随机游走算法
- 下一篇: pLSA概率潜在语义分析