APScheduler API -- apscheduler.triggers.interval
apscheduler.triggers.interval
API
Trigger alias for add_job(): interval
- class 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.interval的更多相关文章
- APScheduler API -- apscheduler.triggers.date
apscheduler.triggers.date API Trigger alias for add_job(): date class apscheduler.triggers.date.Date ...
- APScheduler API -- apscheduler.triggers.cron
apscheduler.triggers.cron API Trigger alias for add_job(): cron class apscheduler.triggers.cron.Cron ...
- APScheduler API -- apscheduler.schedulers.base
apscheduler.schedulers.base API class apscheduler.schedulers.base.BaseScheduler(gconfig={}, **option ...
- Python 定时任务框架 APScheduler 详解
APScheduler 最近想写个任务调度程序,于是研究了下 Python 中的任务调度工具,比较有名的是:Celery,RQ,APScheduler. Celery:非常强大的分布式任务调度框架 R ...
- python APScheduler模块
简介 一般来说Celery是python可以执行定时任务, 但是不支持动态添加定时任务 (Django有插件可以动态添加), 而且对于不需要Celery的项目, 就会让项目变得过重. APSchedu ...
- apscheduler 绿色版
由于依赖EntryPoint,因此apscheduler在离线的方式(直接拷贝然后引用)使用时,会报错. 错误信息类似: No trigger by the name “interval/cron/d ...
- 用apscheduler处理调度任务,定时任务,重复任务
from apscheduler.schedulers.blocking import BlockingScheduler from apscheduler.triggers.cron import ...
- APScheduler 浅析
前言 APScheduler是python下的任务调度框架,全程为Advanced Python Scheduler,是一款轻量级的Python任务调度框架.它允许你像Linux下的Crontab那样 ...
- python定时任务APScheduler
APScheduler定时任务 APScheduler 支持三种调度任务:固定时间间隔,固定时间点(日期),Linux 下的 Crontab 命令.同时,它还支持异步执行.后台执行调度任务. 一.基本 ...
随机推荐
- Majority Number III
Given an array of integers and a number k, the majority number is the number that occursmore than 1/ ...
- day02--Python基础二(基础数据类型)
一.数据与数据类型 1 什么是数据? x=10,10是我们要存储的数据 2 为何数据要分不同的类型 数据是用来表示状态的,不同的状态就应该用不同的类型的数据去表示 3 数据类型 数字(int) 字符串 ...
- IE Only的userData
上次我们提到了本地存储的一个方式,那就是Cookie,不过遗憾的是Cookie保存的数据量非常小,更详细的可以参考<在 Internet Explorer 中的 cookie 的数字和大小限制& ...
- Hibernate Validation,Spring mvc 数据验证框架注解
1.@NotNull:不能为 Null,但是可以为Empty:用在基本数据类型上. @NotNull(message="{state.notnull.valid}", groups ...
- InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,10]
在莫烦Python教程的“Dropout 解决 overfitting”一节中,出现错误如下: InvalidArgumentError: You must feed a value for plac ...
- 【裴蜀定理】【CF1091C】 New Year and the Sphere Transmission
Description 有 \(n\) 个人围成一个圈,按照顺时针从 \(1\) 到 \(n\) 编号.第 \(1\) 个人会拿到一个球,他指定一个数字 \(k\),然后会将球传给他后面顺指针数第 \ ...
- window10+Anaconda3-4.2+python3.5+Pycharm+清华镜像源安装
window下对python3.5适用性比较好,Anaconda4.2里面包含了python3.5. https://mirrors.tuna.tsinghua.edu.cn/anaconda/arc ...
- 布谷鸟搜索算法CS
0 引言 布谷鸟搜索(Cuckoo Search,CS)是由 Xin-She Yang 和 Suash Deb 于 2009 年开发的自然启发式算法.CS 基于布谷鸟的寄生性育雏(brood para ...
- Unmanaged Exports生成Dll时的一些疑难杂症疗法
Unmanaged Exports是一个将.NET编写的静态托管函数导出成可供C/C++等直接调用的非托管函数的工具. 已经在上篇文章介绍过了,这里不再复述. 限制 你不能导出在同一个class中的重 ...
- python3 安装MySQLdb及无法打开mysql.h问题解决(win7 )
在Flask中要连接mysql数据库,需要安装flask-mysqldb. pip install flask-mysqldb 用pip安装MySQLdb 中遇到如下问题,折腾半天之久,多方尝试,终搞 ...