Task Queues & Scheduling

APScheduler

A tiny alarm clock built into your Python program that can ring every minute, every Monday, or the third Tuesday of next March.

Install it: pip install apscheduler

What does it do?

APScheduler lets a running Python program schedule its own tasks, such as run this function every ten minutes or run this every weekday at 9 a.m., without relying on the operating system’s own scheduling tools like cron. It lives inside the application itself, so no separate system configuration is needed; the schedule is just part of the code. It supports simple intervals, calendar-style cron expressions, and one-off run-this-once-at-a-specific-time jobs.

See it in action

This sets up a recurring task that automatically checks an inbox for new messages every ten minutes, without needing a separate calendar or scheduling program.

from apscheduler.schedulers.blocking import BlockingScheduler

scheduler = BlockingScheduler()

@scheduler.scheduled_job("interval", minutes=10)
def check_inbox():
    print("Checking inbox for new messages...")

scheduler.start()

Why would a non-developer care?

Plenty of everyday automated behavior, from a nightly report to a daily database cleanup to a reminder sent at a set time, depends on something scheduling that work reliably. APScheduler is a common way Python developers build that kind of on-a-timer behavior directly into an application rather than depending on separate infrastructure.

Real-world examples

It’s a frequent choice for small to mid-sized applications that need scheduled behavior but don’t want to set up a full external cron system or a heavyweight task queue like Celery just for periodic jobs. Without something like it, a developer might resort to an infinite loop with sleep calls, a fragile approach that breaks the moment the schedule gets more complex than every N seconds.

Who uses it

Developers who need an application to run tasks on a schedule, like periodic reports, cleanup jobs, or reminders, without external scheduling infrastructure.

How it compares to alternatives

Celery has its own scheduler, Celery Beat, for teams already running Celery, while system-level cron remains the classic alternative for anything that doesn’t need to live inside a Python process. APScheduler wins when you want scheduling without adopting a whole separate task queue system.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries