Skip to main content

DjangoSched

轻量级的 Django 定时任务调度框架。基于 Django ORM 与线程/进程实现,支持:

  • 周期任务调度、任务运行日志(SchedulerLog)和锁竞争机制;
  • 嵌入式线程或独立进程运行调度器;
  • 与 Django Admin 集成查看调度器与运行日志。

核心实现与入口

快速开始

  1. 安装(在虚拟环境中):
pip install -e .
  1. 在 Django 项目里加入 django_sched 到 INSTALLED_APPS(示例项目在 demo 中):
INSTALLED_APPS = [
    # ...
    'django_sched',
]
  1. 迁移并启动:
python manage.py migrate
python manage.py runserver

在 runserver 或 gunicorn 下,应用会通过 DjangoSchedConfig.ready() 自动尝试启动调度器(可在日志中看到启动/竞态信息)。详情见 django_sched.apps.DjangoSchedConfig.ready。

以编程方式启动(例如在管理命令中):

from django_sched.sched import start_scheduler
# 在当前进程中以嵌入方式启动(会阻塞)
start_scheduler(embedded_process=True)
# 或作为线程/进程嵌入
start_scheduler(thread=True)

注意事项

  • 锁机制基于数据库表 django_sched_scheduler,当检测到上次持有进程心跳过期时会尝试接管锁;
  • 默认 timezone 配置会影响锁过期与日志时间,请根据项目配置调整;
  • Admin 页面禁止手动新增/修改/删除日志。

贡献与授权

  • 许可:MIT(见 LICENSE)
  • 欢迎提 issue / PR

Metadata

Release files for django-sched 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sched 0.1.3
File Size Uploaded
django_sched-0.1.3.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sched 0.1.3
File Interpreter ABI Platform
django_sched-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / django_sched-0.1.3.tar.gz

Download URL django_sched-0.1.3.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
100b9cf2691988975e6f9fa0e1256ff990938558153772d0b0723b9127506bbc
BLAKE2b-256 checksum
How to use checksums
13c910c5cbdcab937f7c8567187068e1d147681a6c2f749a9803208b025b0aa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Release files / django_sched-0.1.3-py3-none-any.whl

Download URL django_sched-0.1.3-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d832d34cf432d83199e9426d02f75fb686b0cac26d7699326234a16a31d6788d
BLAKE2b-256 checksum
How to use checksums
33642704a28e544b4d9fc5c7082dcb6fddcb5c379be43cf5e8c3285a626c4584
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.14

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page