APScheduler API -- apscheduler.triggers.interval
2014-08-25 19:00
288 查看
apscheduler.triggers.interval
API
Trigger alias for add_job(): intervalclass apscheduler.triggers.interval.IntervalTrigger(weeks=0, days=0, hours=0, minutes=0, seconds=0, start_date=None, end_date=None, timezone=None)
Bases: apscheduler.triggers.base.BaseTrigger
Triggers on specified intervals, starting on start_date if specified, datetime.now() + interval otherwise.
Parameters: | weeks (int) – number of weeks to wait days (int) – number of days to wait hours (int) – number of hours to wait minutes (int) – number of minutes to wait seconds (int) – number of seconds to wait start_date (datetime|str) – starting point for the interval calculation end_date (datetime|str) – latest possible date/time to trigger on timezone (datetime.tzinfo|str) – time zone to use for the date/time calculations |
---|
Introduction
This method schedules jobs to be run periodically, on selected intervals.You can also specify the starting date and ending dates for the schedule through the start_date and end_date parameters, respectively. They can be given as a date/datetime object or text (in the ISO 8601 format).
If the start date is in the past, the trigger will not fire many times retroactively but instead calculates the next run time from the current time, based on the past start time.
Examples
from datetime import datetime from apscheduler.scheduler import BlockingScheduler def job_function(): print("Hello World") sched = BlockingScheduler() # Schedule job_function to be called every two hours sched.add_job(job_function, 'interval', hours=2) sched.start()
You can use start_date and end_date to limit the total time in which the schedule runs:
# The same as before, but starts on 2010-10-10 at 9:30 and stops on 2014-06-15 at 11:00 sched.add_job(job_function, 'interval', hours=2, start_date='2010-10-10 09:30', end_date='2014-06-15 11:00)
The scheduled_job() decorator works nicely too:
from apscheduler.scheduler import BlockingScheduler @sched.scheduled_job('interval', id='my_job_id', hours=2) def job_function(): print("Hello World")
相关文章推荐
- APScheduler API -- apscheduler.triggers.date
- APScheduler API -- apscheduler.schedulers.base
- Python定时任务框架APScheduler 3.0.3 Cron示例
- AP INVOICES IMPORT API(NOT request)
- 创建AP计划付款API
- python APScheduler定时任务框架
- [译]Quartz 框架 教程(中文版)2.2.x 之第二课 Quartz API,Jobs和Triggers简介
- 全面学习ORACLE Scheduler特性(6)设置Repeat Interval参数
- AP INVOICES IMPORT API(NOT request)
- cocos2d-x节点(CCActionInterval.h)API
- APScheduler Multi CronTrigger 实现
- Flask初级(十一)flash与APScheduler 实现定时任务
- Lesson 2: The Quartz API, Jobs And Triggers
- AP INVOICES IMPORT API(NOT request)
- 如何在python的定时任务框架apscheduler中寻找丢失的定时任务
- 【转】Windows 7 API Internet Connection Sharing(ICS) 与 Wireless Hosted Network构建本地AP
- openstack ice自定义调度算法项目详解(horizon、novaclient、api、scheduler、db、自定义数据库)
- Python定时任务APScheduler框架的使用
- cocos2d-x节点(CCActionInterval.h)API