Skip to content

Commit b8d137e

Browse files
committed
Revert "Initial changes for Django 6.0's tasks framework"
This reverts commit 6bc77cf.
1 parent 9ca14c6 commit b8d137e

File tree

23 files changed

+127
-148
lines changed

23 files changed

+127
-148
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Dependencies
2+
## Python
3+
pyproject.toml @herrbenesch @amureki
4+
## GitHub Actions
5+
.github/workflows/ci.yml @herrbenesch @amureki
6+
.github/workflows/release.yml @herrbenesch @amureki

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github:
2+
- amureki
3+
- codingjoe

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ updates:
33
- package-ecosystem: pip
44
directory: "/"
55
schedule:
6-
interval: weekly
6+
interval: daily
77
- package-ecosystem: github-actions
88
directory: "/"
99
schedule:
10-
interval: weekly
10+
interval: daily

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,24 @@ jobs:
2424
os:
2525
- "ubuntu-latest"
2626
python-version:
27+
- "3.10"
28+
- "3.11"
2729
- "3.12"
2830
- "3.13"
29-
- "3.14"
3031
django-version:
31-
- "6.0"
32+
- "4.2" # LTS
33+
- "5.1"
34+
- "5.2"
3235
extras:
3336
- "test"
3437
- "test,sentry"
3538
- "test,redis"
39+
include:
40+
# 4.2 is the last version to support Python 3.9
41+
- os: "ubuntu-latest"
42+
python-version: "3.9"
43+
django-version: "4.2"
44+
extras: "test"
3645
services:
3746
redis:
3847
image: redis

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ dmypy.json
131131

132132
# Packaging
133133

134-
crontask/_version.py
134+
dramatiq_crontab/_version.py

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2025, Johannes Maron, voiio GmbH & contributors
3+
Copyright (c) 2023, voiio GmbH
44

55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,41 @@
1-
# Django CronTask
1+
# Dramatiq Crontab
22

3-
<p align="center">
4-
<picture>
5-
<source media="(prefers-color-scheme: dark)" srcset="./images/logo-dark.svg">
6-
<source media="(prefers-color-scheme: light)" srcset="./images/logo-light.svg">
7-
<img alt="esimport: Blazing fast ESM compiler and importmap generator" src="./images/logo-light.svg">
8-
</picture>
9-
</p>
3+
![dramtiq-crontab logo: person in front of a schedule](https://raw.githubusercontent.com/voiio/dramatiq-crontab/main/dramatiq-crontab.png)
104

11-
**Cron style scheduler for asynchronous tasks in Django.**
5+
**Cron style scheduler for asynchronous Dramatiq tasks in Django.**
126

137
- setup recurring tasks via crontab syntax
14-
- lightweight helpers build [APScheduler]
8+
- lightweight helpers build on robust tools like [Dramatiq] and [APScheduler]
159
- [Sentry] cron monitor support
1610

17-
[![PyPi Version](https://img.shields.io/pypi/v/django-crontask.svg)](https://pypi.python.org/pypi/django-crontask/)
18-
[![Test Coverage](https://codecov.io/gh/codingjoe/django-crontask/branch/main/graph/badge.svg)](https://codecov.io/gh/codingjoe/django-crontask)
19-
[![GitHub License](https://img.shields.io/github/license/codingjoe/django-crontask)](https://raw.githubusercontent.com/codingjoe/django-crontask/master/LICENSE)
11+
[![PyPi Version](https://img.shields.io/pypi/v/dramatiq-crontab.svg)](https://pypi.python.org/pypi/dramatiq-crontab/)
12+
[![Test Coverage](https://codecov.io/gh/voiio/dramatiq-crontab/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/dramatiq-crontab)
13+
[![GitHub License](https://img.shields.io/github/license/voiio/dramatiq-crontab)](https://raw.githubusercontent.com/voiio/dramatiq-crontab/master/LICENSE)
2014

2115
## Setup
2216

23-
You need to have [Django's Task framework][django-tasks] setup properly.
17+
You need to have [Dramatiq] installed and setup properly.
2418

2519
```ShellSession
26-
python3 -m pip install django-crontask
20+
python3 -m pip install dramatiq-crontab
2721
# or
28-
python3 -m pip install django-crontask[sentry] # with sentry cron monitor support
22+
python3 -m pip install dramatiq-crontab[sentry] # with sentry cron monitor support
2923
```
3024

31-
Add `crontask` to your `INSTALLED_APPS` in `settings.py`:
25+
Add `dramatiq_crontab` to your `INSTALLED_APPS` in `settings.py`:
3226

3327
```python
3428
# settings.py
3529
INSTALLED_APPS = [
36-
"crontask",
30+
"dramatiq_crontab",
3731
# ...
3832
]
3933
```
4034

4135
Finally, you lauch the scheduler in a separate process:
4236

4337
```ShellSession
44-
python3 manage.py crontask
38+
python3 manage.py crontab
4539
```
4640

4741
### Setup Redis as a lock backend (optional)
@@ -53,7 +47,7 @@ instances of your application running.
5347

5448
```python
5549
# settings.py
56-
CRONTASK = {
50+
DRAMATIQ_CRONTAB = {
5751
"REDIS_URL": "redis://localhost:6379/0",
5852
}
5953
```
@@ -62,12 +56,12 @@ CRONTASK = {
6256

6357
```python
6458
# tasks.py
65-
from django.tasks import task
66-
from crontask import cron
59+
import dramatiq
60+
from dramatiq_crontab import cron
6761

6862

6963
@cron("*/5 * * * *") # every 5 minutes
70-
@task
64+
@dramatiq.actor
7165
def my_task():
7266
my_task.logger.info("Hello World")
7367
```
@@ -79,12 +73,12 @@ If you want to run a task more frequently than once a minute, you can use the
7973

8074
```python
8175
# tasks.py
82-
from django.tasks import task
83-
from crontask import interval
76+
import dramatiq
77+
from dramatiq_crontab import interval
8478

8579

8680
@interval(seconds=30)
87-
@task
81+
@dramatiq.actor
8882
def my_task():
8983
my_task.logger.info("Hello World")
9084
```
@@ -107,7 +101,7 @@ usage: manage.py crontab [-h] [--no-task-loading] [--no-heartbeat] [--version] [
107101
[--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
108102
[--force-color] [--skip-checks]
109103

110-
Run task scheduler for all tasks with the `cron` decorator.
104+
Run dramatiq task scheduler for all tasks with the `cron` decorator.
111105

112106
options:
113107
-h, --help show this help message and exit
@@ -116,5 +110,5 @@ options:
116110
```
117111

118112
[apscheduler]: https://apscheduler.readthedocs.io/en/stable/
119-
[django-tasks]: https://docs.djangoproject.com/en/6.0/topics/tasks/
113+
[dramatiq]: https://dramatiq.io/
120114
[sentry]: https://docs.sentry.io/product/crons/

crontask/tasks.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Cron style scheduler for Django's task framework."""
1+
"""Cron style scheduler for asynchronous Dramatiq tasks in Django."""
22

33
from unittest.mock import Mock
44

@@ -42,7 +42,7 @@ def cron(schedule):
4242
4343
Usage:
4444
@cron("0 0 * * *")
45-
@task
45+
@dramatiq.actor
4646
def cron_test():
4747
print("Cron test")
4848
@@ -55,7 +55,7 @@ def cron_test():
5555
The monitors timezone should be set to Europe/Berlin.
5656
"""
5757

58-
def decorator(task):
58+
def decorator(actor):
5959
*_, day_schedule = schedule.split(" ")
6060

6161
# CronTrigger uses Python's timezone dependent first weekday,
@@ -67,26 +67,19 @@ def decorator(task):
6767
)
6868

6969
if monitor is not None:
70-
task = type(task)(
71-
priority=task.priority,
72-
func=monitor(task.name)(task.func),
73-
queue_name=task.queue_name,
74-
backend=task.backend,
75-
takes_context=task.takes_context,
76-
run_after=task.run_after,
77-
)
70+
actor.fn = monitor(actor.actor_name)(actor.fn)
7871

7972
scheduler.add_job(
80-
task.enqueue,
73+
actor.send,
8174
CronTrigger.from_crontab(
8275
schedule,
8376
timezone=timezone.get_default_timezone(),
8477
),
85-
name=task.name,
78+
name=actor.actor_name,
8679
)
8780
# We don't add the Sentry monitor on the actor itself, because we only want to
8881
# monitor the cron job, not the actor itself, or it's direct invocations.
89-
return task
82+
return actor
9083

9184
return decorator
9285

@@ -97,7 +90,7 @@ def interval(*, seconds):
9790
9891
Usage:
9992
@interval(seconds=30)
100-
@task
93+
@dramatiq.actor
10194
def interval_test():
10295
print("Interval test")
10396
@@ -109,25 +102,18 @@ def interval_test():
109102
For an interval that is consistent with the clock, use the `cron` decorator instead.
110103
"""
111104

112-
def decorator(task):
105+
def decorator(actor):
113106
if monitor is not None:
114-
task = type(task)(
115-
priority=task.priority,
116-
func=monitor(task.name)(task.func),
117-
queue_name=task.queue_name,
118-
backend=task.backend,
119-
takes_context=task.takes_context,
120-
run_after=task.run_after,
121-
)
107+
actor.fn = monitor(actor.actor_name)(actor.fn)
122108

123109
scheduler.add_job(
124-
task.enqueue,
110+
actor.send,
125111
IntervalTrigger(
126112
seconds=seconds,
127113
timezone=timezone.get_default_timezone(),
128114
),
129-
name=task.name,
115+
name=actor.actor_name,
130116
)
131-
return task
117+
return actor
132118

133119
return decorator
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def get_settings():
1212
"LOCK_REFRESH_INTERVAL": 5,
1313
"LOCK_TIMEOUT": 10,
1414
"LOCK_BLOCKING_TIMEOUT": 15,
15-
**getattr(settings, "CRONTASK", {}),
15+
**getattr(settings, "DRAMATIQ_CRONTAB", {}),
1616
},
1717
)

0 commit comments

Comments
 (0)