Skip to content

Models

ScheduledTask

class django_periodic_tasks.models.ScheduledTask(*args, **kwargs)

A persistent record of a periodic task and its cron schedule.

Each row represents one scheduled task. The scheduler queries this table on every tick to find tasks whose next_run_at has passed, then enqueues them via django-tasks.

Tasks can originate from two sources (see :class:Source):

  • Code-defined — registered with :func:~django_periodic_tasks.registry.scheduled_task and synced to the database on scheduler startup.
  • Database-defined — created manually through the Django admin.

ScheduledTask.Source

Where a scheduled task definition comes from.

  • CODE — Managed by the codebase and synced automatically on scheduler startup.
  • DATABASE — Managed by operators through the Django admin.

TaskExecution

class django_periodic_tasks.models.TaskExecution(*args, **kwargs)

An execution permit for a single scheduled task invocation.

Used by the @exactly_once decorator to ensure a task runs at most once per scheduled invocation, even with non-transactional backends (e.g. Redis/RQ).

TaskExecution.Status

The lifecycle status of an execution permit.

  • PENDING — Created by the scheduler, awaiting worker pickup.
  • COMPLETED — The @exactly_once decorator ran the task successfully.