django-crontask 1.3.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_crontask-1.3.0 → django_crontask-2.0.1}/PKG-INFO +11 -3
- {django_crontask-1.3.0 → django_crontask-2.0.1}/README.md +10 -2
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/__init__.py +8 -29
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/_version.py +3 -3
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/contrib/sentry.py +1 -1
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/management/commands/crontask.py +3 -1
- {django_crontask-1.3.0 → django_crontask-2.0.1}/LICENSE +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/conf.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/contrib/__init__.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/management/__init__.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/management/commands/__init__.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/tasks.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/crontask/utils.py +0 -0
- {django_crontask-1.3.0 → django_crontask-2.0.1}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-crontask
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Cron style scheduler for Django's task framework.
|
|
5
5
|
Keywords: Django,cron,tasks,scheduler
|
|
6
6
|
Author-email: Rust Saiargaliev <fly.amureki@gmail.com>, Johannes Maron <johannes@maron.family>, Mostafa Mohamed <mostafa.anm91@gmail.com>, Jacqueline Kraus <jacquelinekraus1992@gmail.com>
|
|
@@ -60,8 +60,15 @@ Provides-Extra: sentry
|
|
|
60
60
|
[](https://codecov.io/gh/codingjoe/django-crontask)
|
|
61
61
|
[](https://raw.githubusercontent.com/codingjoe/django-crontask/master/LICENSE)
|
|
62
62
|
|
|
63
|
+
## Sponsors
|
|
64
|
+
|
|
65
|
+
[](https://github.com/sponsors/codingjoe)
|
|
66
|
+
|
|
63
67
|
## Setup
|
|
64
68
|
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> Still need a reliable task backend? Check out [Threadmill]!
|
|
71
|
+
|
|
65
72
|
You need to have [Django's Task framework][django-tasks] setup properly.
|
|
66
73
|
|
|
67
74
|
```ShellSession
|
|
@@ -152,11 +159,11 @@ The monitor's slug will be the actor's name. Like `my_task` in the example above
|
|
|
152
159
|
Certain triggers are not supported by Sentry as well as sub-minute intervals.
|
|
153
160
|
In these cases, no monitor will be created and no telemetry will be sent.
|
|
154
161
|
|
|
155
|
-
Pass a custom config via `sentry_monitor_config` or set it to `
|
|
162
|
+
Pass a custom config via `sentry_monitor_config` or set it to `None`
|
|
156
163
|
to disable Sentry monitoring for a single task:
|
|
157
164
|
|
|
158
165
|
```python
|
|
159
|
-
@cron("* * * * *", sentry_monitor_config=
|
|
166
|
+
@cron("* * * * *", sentry_monitor_config=None)
|
|
160
167
|
@task
|
|
161
168
|
def my_task_without_sentry(): ...
|
|
162
169
|
```
|
|
@@ -180,4 +187,5 @@ options:
|
|
|
180
187
|
[apscheduler]: https://apscheduler.readthedocs.io/en/stable/
|
|
181
188
|
[django-tasks]: https://docs.djangoproject.com/en/6.0/topics/tasks/
|
|
182
189
|
[sentry]: https://docs.sentry.io/product/crons/
|
|
190
|
+
[threadmill]: https://github.com/codingjoe/threadmill
|
|
183
191
|
|
|
@@ -18,8 +18,15 @@
|
|
|
18
18
|
[](https://codecov.io/gh/codingjoe/django-crontask)
|
|
19
19
|
[](https://raw.githubusercontent.com/codingjoe/django-crontask/master/LICENSE)
|
|
20
20
|
|
|
21
|
+
## Sponsors
|
|
22
|
+
|
|
23
|
+
[](https://github.com/sponsors/codingjoe)
|
|
24
|
+
|
|
21
25
|
## Setup
|
|
22
26
|
|
|
27
|
+
> [!NOTE]
|
|
28
|
+
> Still need a reliable task backend? Check out [Threadmill]!
|
|
29
|
+
|
|
23
30
|
You need to have [Django's Task framework][django-tasks] setup properly.
|
|
24
31
|
|
|
25
32
|
```ShellSession
|
|
@@ -110,11 +117,11 @@ The monitor's slug will be the actor's name. Like `my_task` in the example above
|
|
|
110
117
|
Certain triggers are not supported by Sentry as well as sub-minute intervals.
|
|
111
118
|
In these cases, no monitor will be created and no telemetry will be sent.
|
|
112
119
|
|
|
113
|
-
Pass a custom config via `sentry_monitor_config` or set it to `
|
|
120
|
+
Pass a custom config via `sentry_monitor_config` or set it to `None`
|
|
114
121
|
to disable Sentry monitoring for a single task:
|
|
115
122
|
|
|
116
123
|
```python
|
|
117
|
-
@cron("* * * * *", sentry_monitor_config=
|
|
124
|
+
@cron("* * * * *", sentry_monitor_config=None)
|
|
118
125
|
@task
|
|
119
126
|
def my_task_without_sentry(): ...
|
|
120
127
|
```
|
|
@@ -138,3 +145,4 @@ options:
|
|
|
138
145
|
[apscheduler]: https://apscheduler.readthedocs.io/en/stable/
|
|
139
146
|
[django-tasks]: https://docs.djangoproject.com/en/6.0/topics/tasks/
|
|
140
147
|
[sentry]: https://docs.sentry.io/product/crons/
|
|
148
|
+
[threadmill]: https://github.com/codingjoe/threadmill
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"""Cron style scheduler for Django's task framework."""
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
import warnings
|
|
5
4
|
from unittest.mock import Mock
|
|
6
5
|
|
|
7
6
|
from apscheduler.schedulers.base import STATE_STOPPED
|
|
8
7
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
9
8
|
from apscheduler.triggers.base import BaseTrigger
|
|
10
9
|
from apscheduler.triggers.cron import CronTrigger
|
|
11
|
-
from apscheduler.triggers.interval import IntervalTrigger
|
|
12
10
|
from django.tasks import Task
|
|
13
11
|
from django.utils import timezone
|
|
14
12
|
|
|
15
13
|
from . import _version
|
|
16
14
|
from .contrib import sentry
|
|
17
15
|
|
|
18
|
-
__all__ = ["cron", "
|
|
16
|
+
__all__ = ["cron", "scheduler", "VERSION", "__version__"]
|
|
19
17
|
|
|
20
18
|
__version__ = _version.version
|
|
21
19
|
VERSION = _version.version_tuple
|
|
@@ -34,12 +32,13 @@ class LazyBlockingScheduler(BlockingScheduler):
|
|
|
34
32
|
|
|
35
33
|
|
|
36
34
|
scheduler = LazyBlockingScheduler()
|
|
35
|
+
UNSET = object()
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
def cron(
|
|
40
39
|
schedule: str | BaseTrigger,
|
|
41
40
|
*,
|
|
42
|
-
sentry_monitor_config: dict[str,
|
|
41
|
+
sentry_monitor_config: dict[str, dict[str, str | int] | str] | None = UNSET,
|
|
43
42
|
) -> typing.Callable[[Task], Task]:
|
|
44
43
|
"""
|
|
45
44
|
Run task on a scheduler with a cron schedule.
|
|
@@ -52,7 +51,7 @@ def cron(
|
|
|
52
51
|
|
|
53
52
|
Args:
|
|
54
53
|
schedule: A cron schedule string or an APScheduler trigger.
|
|
55
|
-
sentry_monitor_config: A Sentry monitor configuration dict or
|
|
54
|
+
sentry_monitor_config: A Sentry monitor configuration dict or None to disable monitoring.
|
|
56
55
|
|
|
57
56
|
"""
|
|
58
57
|
|
|
@@ -73,11 +72,13 @@ def cron(
|
|
|
73
72
|
else:
|
|
74
73
|
trigger = schedule
|
|
75
74
|
|
|
76
|
-
if sentry_monitor_config is not
|
|
75
|
+
if sentry_monitor_config is not None:
|
|
77
76
|
task = sentry.monitor_cron_task(
|
|
78
77
|
task,
|
|
79
78
|
trigger,
|
|
80
|
-
sentry_monitor_config=
|
|
79
|
+
sentry_monitor_config={}
|
|
80
|
+
if sentry_monitor_config is UNSET
|
|
81
|
+
else sentry_monitor_config,
|
|
81
82
|
)
|
|
82
83
|
|
|
83
84
|
scheduler.add_job(
|
|
@@ -90,25 +91,3 @@ def cron(
|
|
|
90
91
|
return task
|
|
91
92
|
|
|
92
93
|
return decorator
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def interval(*, seconds):
|
|
96
|
-
"""
|
|
97
|
-
Run task on a periodic interval.
|
|
98
|
-
|
|
99
|
-
The interval decorator is deprecated and will be removed in a future release.
|
|
100
|
-
Please use the cron decorator with an 'IntervalTrigger' instead.
|
|
101
|
-
"""
|
|
102
|
-
warnings.warn(
|
|
103
|
-
"The interval decorator is deprecated and will be removed in a future release. "
|
|
104
|
-
"Please use the cron decorator with an 'IntervalTrigger' instead.",
|
|
105
|
-
DeprecationWarning,
|
|
106
|
-
stacklevel=2,
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
return cron(
|
|
110
|
-
IntervalTrigger(
|
|
111
|
-
seconds=seconds,
|
|
112
|
-
timezone=timezone.get_default_timezone(),
|
|
113
|
-
)
|
|
114
|
-
)
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '
|
|
22
|
-
__version_tuple__ = version_tuple = (
|
|
21
|
+
__version__ = version = '2.0.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 0, 1)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'gdd8eb0ca2'
|
|
@@ -65,7 +65,7 @@ def trigger_to_monitor_config(
|
|
|
65
65
|
def monitor_cron_task(
|
|
66
66
|
task: Task,
|
|
67
67
|
trigger: BaseTrigger,
|
|
68
|
-
sentry_monitor_config: dict[str, dict[str, str | int] | str]
|
|
68
|
+
sentry_monitor_config: dict[str, dict[str, str | int] | str],
|
|
69
69
|
) -> Task:
|
|
70
70
|
"""
|
|
71
71
|
Wrap the task function in a Sentry monitor for a suitable trigger.
|
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
from apscheduler.triggers.interval import IntervalTrigger
|
|
6
6
|
from django.apps import apps
|
|
7
7
|
from django.core.management import BaseCommand
|
|
8
|
+
from django.utils.module_loading import module_has_submodule
|
|
8
9
|
|
|
9
10
|
from ... import conf, utils
|
|
10
11
|
|
|
@@ -102,4 +103,5 @@ class Command(BaseCommand):
|
|
|
102
103
|
f"Loaded tasks from {self.style.NOTICE(app.name)}."
|
|
103
104
|
)
|
|
104
105
|
except ImportError:
|
|
105
|
-
|
|
106
|
+
if module_has_submodule(app.module, "tasks"):
|
|
107
|
+
raise
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|