APScheduler API -- apscheduler.schedulers.base
apscheduler.schedulers.base
API
- class apscheduler.schedulers.base.BaseScheduler(gconfig={}, **options)
-
Abstract base class for all schedulers. Takes the following keyword arguments:
Parameters: - logger (str|logging.Logger) – logger to use for the scheduler’s logging (defaults to apscheduler.scheduler)
- timezone (str|datetime.tzinfo) – the default time zone (defaults to the local timezone)
- job_defaults (dict) – default values for newly added jobs
- jobstores (dict) – a dictionary of job store alias -> job store instance or configuration dict
- executors (dict) – a dictionary of executor alias -> executor instance or configuration dict
See also
- add_executor(executor, alias='default', **executor_opts)
-
Adds an executor to this scheduler. Any extra keyword arguments will be passed to the executor plugin’s constructor, assuming that the first argument is the name of an executor plugin.
Parameters: - executor (str|unicode|apscheduler.executors.base.BaseExecutor) – either an executor instance or the name of an executor plugin
- alias (str|unicode) – alias for the scheduler
Raises ValueError: if there is already an executor by the given alias
- add_job(func, trigger=None, args=None, kwargs=None, id=None, name=None, misfire_grace_time=undefined, coalesce=undefined, max_instances=undefined, next_run_time=undefined, jobstore='default', executor='default', replace_existing=False, **trigger_args)
-
Adds the given job to the job list and wakes up the scheduler if it’s already running.
Any option that defaults to undefined will be replaced with the corresponding default value when the job is scheduled (which happens when the scheduler is started, or immediately if the scheduler is already running).
The func argument can be given either as a callable object or a textual reference in the package.module:some.object format, where the first half (separated by :) is an importable module and the second half is a reference to the callable object, relative to the module.
- The trigger argument can either be:
-
- the alias name of the trigger (e.g. date, interval or cron), in which case any extra keyword arguments to this method are passed on to the trigger’s constructor
- an instance of a trigger class
Parameters: - func – callable (or a textual reference to one) to run at the given time
- trigger (str|apscheduler.triggers.base.BaseTrigger) – trigger that determines when func is called
- args (list|tuple) – list of positional arguments to call func with
- kwargs (dict) – dict of keyword arguments to call func with
- id (str|unicode) – explicit identifier for the job (for modifying it later)
- name (str|unicode) – textual description of the job
- misfire_grace_time (int) – seconds after the designated run time that the job is still allowed to be run
- coalesce (bool) – run once instead of many times if the scheduler determines that the job should be run more than once in succession
- max_instances (int) – maximum number of concurrently running instances allowed for this job
- next_run_time (datetime) – when to first run the job, regardless of the trigger (pass None to add the job as paused)
- jobstore (str|unicode) – alias of the job store to store the job in
- executor (str|unicode) – alias of the executor to run the job with
- replace_existing (bool) – True to replace an existing job with the same id (but retain the number of runs from the existing one)
Return type: Job
- add_jobstore(jobstore, alias='default', **jobstore_opts)
-
Adds a job store to this scheduler. Any extra keyword arguments will be passed to the job store plugin’s constructor, assuming that the first argument is the name of a job store plugin.
Parameters: - jobstore (str|unicode|apscheduler.jobstores.base.BaseJobStore) – job store to be added
- alias (str|unicode) – alias for the job store
Raises ValueError: if there is already a job store by the given alias
- add_listener(callback, mask=EVENT_ALL)
-
Adds a listener for scheduler events. When a matching event occurs, callback is executed with the event object as its sole argument. If the mask parameter is not provided, the callback will receive events of all types.
Parameters: - callback – any callable that takes one argument
- mask (int) – bitmask that indicates which events should be listened to
See also
See also
- configure(gconfig={}, prefix='apscheduler.', **options)
-
Reconfigures the scheduler with the given options. Can only be done when the scheduler isn’t running.
Parameters: - gconfig (dict) – a “global” configuration dictionary whose values can be overridden by keyword arguments to this method
- prefix (str|unicode) – pick only those keys from gconfig that are prefixed with this string (pass an empty string or None to use all keys)
Raises SchedulerAlreadyRunningError: if the scheduler is already running
- get_job(job_id, jobstore=None)
-
Returns the Job that matches the given job_id.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that most likely contains the job
Returns: the Job by the given ID, or None if it wasn’t found
Return type: Job
- get_jobs(jobstore=None, pending=None)
-
Returns a list of pending jobs (if the scheduler hasn’t been started yet) and scheduled jobs, either from a specific job store or from all of them.
Parameters: - jobstore (str|unicode) – alias of the job store
- pending (bool) – False to leave out pending jobs (jobs that are waiting for the scheduler start to be added to their respective job stores), True to only include pending jobs, anything else to return both
Return type: list[Job]
- modify_job(job_id, jobstore=None, **changes)
-
Modifies the properties of a single job. Modifications are passed to this method as extra keyword arguments.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that contains the job
- pause_job(job_id, jobstore=None)
-
Causes the given job not to be executed until it is explicitly resumed.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that contains the job
- print_jobs(jobstore=None, out=sys.stdout)
-
Prints out a textual listing of all jobs currently scheduled on either all job stores or just a specific one.
Parameters: - jobstore (str|unicode) – alias of the job store, None to list jobs from all stores
- out (file) – a file-like object to print to (defaults to sys.stdout if nothing is given)
- remove_all_jobs(jobstore=None)
-
Removes all jobs from the specified job store, or all job stores if none is given.
Parameters: jobstore (str|unicode) – alias of the job store
- remove_executor(alias, shutdown=True)
-
Removes the executor by the given alias from this scheduler.
Parameters: - alias (str|unicode) – alias of the executor
- shutdown (bool) – True to shut down the executor after removing it
- remove_job(job_id, jobstore=None)
-
Removes a job, preventing it from being run any more.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that contains the job
Raises JobLookupError: if the job was not found
- remove_jobstore(alias, shutdown=True)
-
Removes the job store by the given alias from this scheduler.
Parameters: - alias (str|unicode) – alias of the job store
- shutdown (bool) – True to shut down the job store after removing it
- remove_listener(callback)
-
Removes a previously added event listener.
- reschedule_job(job_id, jobstore=None, trigger=None, **trigger_args)
-
Constructs a new trigger for a job and updates its next run time. Extra keyword arguments are passed directly to the trigger’s constructor.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that contains the job
- trigger – alias of the trigger type or a trigger instance
- resume_job(job_id, jobstore=None)
-
Resumes the schedule of the given job, or removes the job if its schedule is finished.
Parameters: - job_id (str|unicode) – the identifier of the job
- jobstore (str|unicode) – alias of the job store that contains the job
- scheduled_job(trigger, args=None, kwargs=None, id=None, name=None, misfire_grace_time=undefined, coalesce=undefined, max_instances=undefined, next_run_time=undefined, jobstore='default', executor='default', **trigger_args)
-
A decorator version of add_job(), except that replace_existing is always True.
Important
The id argument must be given if scheduling a job in a persistent job store. The scheduler cannot, however, enforce this requirement.
- shutdown(wait=True)
-
Shuts down the scheduler. Does not interrupt any currently running jobs.
Parameters: wait (bool) – True to wait until all currently executing jobs have finished Raises SchedulerNotRunningError: if the scheduler has not been started yet
- start()
-
Starts the scheduler. The details of this process depend on the implementation.
Raises SchedulerAlreadyRunningError: if the scheduler is already running
- wakeup()
-
Notifies the scheduler that there may be jobs due for execution. Triggers _process_jobs() to be run in an implementation specific manner.
APScheduler API -- apscheduler.schedulers.base的更多相关文章
- APScheduler API -- apscheduler.triggers.interval
apscheduler.triggers.interval API Trigger alias for add_job(): interval class apscheduler.triggers.i ...
- 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
安装 APScheduler $ pip install apscheduler 快速开始 from apscheduler.schedulers.blocking import BlockingSc ...
- Python 定时任务框架 APScheduler 详解
APScheduler 最近想写个任务调度程序,于是研究了下 Python 中的任务调度工具,比较有名的是:Celery,RQ,APScheduler. Celery:非常强大的分布式任务调度框架 R ...
- python 定时任务APScheduler 使用介绍
python 定时任务APScheduler 使用介绍 介绍: APScheduler的全称是Advanced Python Scheduler.它是一个轻量级的 Python 定时任务调度框架. ...
- Python任务调度模块 – APScheduler
APScheduler是一个Python定时任务框架,使用起来十分方便.提供了基于日期.固定时间间隔以及crontab类型的任务,并且可以持久化任务.并以daemon方式运行应用.目前最新版本为3.0 ...
- python3使用pyinstaller打包apscheduler出的错
本来只是想用Python做一个定时任务小工具在服务器上运行,可是服务器在隔离区,各种禁止上外网,使用pip导出列表那种下载库的方法不管用,导致Python的各种库都下不到,官网离线下载又各种缺依赖,好 ...
- 定时任务框架APScheduler学习详解
APScheduler简介 在平常的工作中几乎有一半的功能模块都需要定时任务来推动,例如项目中有一个定时统计程序,定时爬出网站的URL程序,定时检测钓鱼网站的程序等等,都涉及到了关于定时任务的问题,第 ...
随机推荐
- (转)Python中如何理解if __name__ == '__main__'
摘要 通俗的理解 __name__ == '__main__' :假如你叫李凯.py,在朋友眼中,你是李凯( __name__ == '李凯' ):在你自己眼中,你是你自己( __name__ == ...
- Qt——用于表格QTableView的模型
如果想使用表格来呈现数据,Qt提供了一个方便的部件QTableWidget,但是直接用它实现一些功能可能比较困难.这里将介绍一种强大.灵活的方式来操作表格. 一.模型/视图架构 在这个架构中,模型用于 ...
- c# 方法参数 params 的试用
//添加方法 public void test(params string[] messages) { } //调用方法 test("aaa","bbb",&q ...
- 【JQuery】Ajax
一.前言 接着上一章的内容,继续本章的学习.本章知识来自于https://www.cnblogs.com/jach/p/5709175.html 二.内容 $.ajax({ url:'/ ...
- 洛谷P5283 & LOJ3048:[十二省联考2019]异或粽子——题解
https://www.luogu.org/problemnew/show/P5283 https://loj.ac/problem/3048 小粽是一个喜欢吃粽子的好孩子.今天她在家里自己做起了粽子 ...
- uoj318 [NOI2017]蔬菜 【贪心 + 堆 + 并查集】
题目链接 uoj 题解 以前看别人博客,在考场上用费用流做,一直以为这题是毒瘤网络流题 没想到竟然是贪心模拟题... 如果只有一个蔬菜呢?这就是一个经典的普及难度的贪心,正着推面临优先选择的困难,而逆 ...
- CentOS安装oracleJDK
实践证明,oracleJDK比openJDK快不止一星半点,换了之后立马从满负载降到个位数负载. 1.卸载openjdk # rpm -qa | grep -E '^(java|jdk)' # yum ...
- java多线程 -- 同步鎖
为了解决多线程安全问题在 Java 5.0 之前,协调共享对象的访问时可以使用的机制只有 synchronized 和 volatile .Java 5.0 后增加了一些新的机制,但并不是一种替代内置 ...
- Android Intent 总结
//打开指定网页Intent intent = new Intent(Intent.ACTION_VIEW);intent.setData(Uri.parse("http://www.goo ...
- 解题:ZJOI 2015 幻想乡战略游戏
题面 神**所有点都爆int,我还以为我写出什么大锅了,不开long long见祖宗... 动态点分治利用点分树树高不超过log的性质,我们对每个点维护一个子树和,一个点分树子树和,一个点分树上父亲的 ...