Metadata-Version: 2.4
Name: django-tasks-scheduler
Version: 4.1.0
Summary: An async job scheduler for django using redis/valkey brokers
Project-URL: Bug Tracker, https://github.com/django-commons/django-tasks-scheduler/issues
Project-URL: Documentation, https://django-tasks-scheduler.readthedocs.io/
Project-URL: Funding, https://github.com/sponsors/cunla
Project-URL: Homepage, https://github.com/django-commons/django-tasks-scheduler
Author-email: Daniel Moran <daniel@moransoftware.ca>
Maintainer-email: Daniel Moran <daniel@moransoftware.ca>
License-Expression: MIT
License-File: LICENSE
Keywords: background-jobs,django,job-queue,redis,redis-queue,scheduled-jobs,task-queue,valkey
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: click~=8.2
Requires-Dist: croniter>=2
Requires-Dist: django>=5
Requires-Dist: typing-extensions>=4.15
Provides-Extra: sentry
Requires-Dist: sentry-sdk~=2.19; extra == 'sentry'
Provides-Extra: valkey
Requires-Dist: valkey>=6.0.2; extra == 'valkey'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6; extra == 'yaml'
Requires-Dist: types-pyyaml>=6.0.12.20250516; extra == 'yaml'
Description-Content-Type: text/markdown

Django Tasks Scheduler
===================
[![Django CI](https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml/badge.svg)](https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml)
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/cunla/b756396efb895f0e34558c980f1ca0c7/raw/django-tasks-scheduler-4.json)
[![badge](https://img.shields.io/pypi/dm/django-tasks-scheduler)](https://pypi.org/project/django-tasks-scheduler/)

Documentation can be found in https://django-tasks-scheduler.readthedocs.io/

## Introduction Video

[![Django Tasks Scheduler Introduction](https://img.youtube.com/vi/Brfavid_fxw/0.jpg)](https://www.youtube.com/watch?v=Brfavid_fxw)

Watch this introduction video to learn about django-tasks-scheduler and its features.

# Usage

1. Update `settings.py` to include scheduler configuration:

```python
import os
from typing import Dict
from scheduler.types import SchedulerConfiguration, Broker, QueueConfiguration

INSTALLED_APPS = [
    # ...
    'scheduler',
    # ...
]
SCHEDULER_CONFIG = SchedulerConfiguration(
    EXECUTIONS_IN_PAGE=20,
    SCHEDULER_INTERVAL=10,
    BROKER=Broker.REDIS,
    CALLBACK_TIMEOUT=60,  # Callback timeout in seconds (success/failure/stopped)
    # Default values, can be overridden per task/job
    DEFAULT_SUCCESS_TTL=10 * 60,  # Time To Live (TTL) in seconds to keep successful job results
    DEFAULT_FAILURE_TTL=365 * 24 * 60 * 60,  # Time To Live (TTL) in seconds to keep job failure information
    DEFAULT_JOB_TTL=10 * 60,  # Time To Live (TTL) in seconds to keep job information
    DEFAULT_JOB_TIMEOUT=5 * 60,  # timeout (seconds) for a job
    # General configuration values
    DEFAULT_WORKER_TTL=10 * 60,  # Time To Live (TTL) in seconds to keep worker information after last heartbeat
    DEFAULT_MAINTENANCE_TASK_INTERVAL=10 * 60,  # The interval to run maintenance tasks in seconds. 10 minutes.
    DEFAULT_JOB_MONITORING_INTERVAL=30,  # The interval to monitor jobs in seconds.
    SCHEDULER_FALLBACK_PERIOD_SECS=120,  # Period (secs) to wait before requiring to reacquire locks
)
SCHEDULER_QUEUES: Dict[str, QueueConfiguration] = {
    'default': QueueConfiguration(URL='redis://localhost:6379/0'),
}
```

2. Update `urls.py` to include scheduler urls:

```python
from django.urls import path, include

urlpatterns = [
    # ...
    path('scheduler/', include('scheduler.urls')),
]
```

3. Run migrations:

```bash
python manage.py migrate
```

4. Check out the admin views:
   ![](./docs/media/admin-tasks-list.jpg)


# Local development environment

You can install [`pre-commit` hook](https://pre-commit.com/) in the repo to add it as a git hook by
running: `pre-commit install`. It is configured to check all change files based on configuration in
`.pre-commit-config.yaml`.

# Sponsor

django-tasks-scheduler is developed for free.

You can support this project by becoming a sponsor using [this link](https://github.com/sponsors/cunla).

# Contributing

Interested in contributing, providing suggestions, or submitting bugs? See
guidelines [at this link](.github/CONTRIBUTING.md).
