API Reference

APScheduler

In-process task scheduler for Python with cron, interval and date triggers plus pluggable job stores.

Official Documentation ↗
CompatibilityThis documentation covers version APScheduler 3.10+ / Python 3.9+. Check the official docs for the latest API surface.

Installation

pippip install apscheduler

Methods

Overview

APScheduler schedules Python callables using cron, interval or date triggers, running them in a background thread or asyncio loop. Job stores and executors can be swapped for persistence and concurrency control.

Core Methods

Choose a scheduler, start it, and add jobs with add_job, specifying a trigger and an id. Job stores persist schedules, and executors decide where jobs run.

Usage Notes

Use replace_existing with stable job ids to avoid duplicates on restart, set max_instances to avoid overlap, and persist jobs when the process restarts often.

Common Pitfalls

The memory job store loses jobs on restart. Multiple schedulers sharing a store can duplicate execution. Blocking work in the scheduler thread delays other jobs, so keep jobs short or offload them.

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T19:27:00+08:00 via WebFetch https://apscheduler.readthedocs.io/en/stable/modules/schedulers/base.html;WebFetch https://apscheduler.readthedocs.io/en/stable/modules/schedulers/background.html.

FAQ

Does the scheduler persist jobs by default?
No. The default memory store loses jobs on restart. Configure a persistent job store such as SQLAlchemy or a supported backend to keep schedules across restarts.
How do multiple workers behave?
Each process runs its own scheduler, so a persisted store shared by several workers can fire a job more than once unless a lock or a single-scheduler design prevents it.
What happens when a job overruns?
By default the next run can start before the previous finishes, causing overlap. Set max_instances and misfire_grace_time to control concurrency and late execution.