mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 06:58:11 +08:00
Allow tasks to be scheduled on a specific cluster (#555)
* Allows schedule by cluster * Update docs * Add example in doc * Fixes cluster field must be blank * Adds cluster arg to schedule func * Adds cluster field in list_display/filter for admin * Uses Q filter to fetch schedule * Fixes ref in doc * Adds tests
This commit is contained in:
@@ -88,6 +88,7 @@ def schedule(func, *args, **kwargs):
|
||||
:param repeats: how many times to repeat. 0=never, -1=always.
|
||||
:param next_run: Next scheduled run.
|
||||
:type next_run: datetime.datetime
|
||||
:param cluster: optional cluster name.
|
||||
:param cron: optional cron expression
|
||||
:param kwargs: function keyword arguments.
|
||||
:return: the schedule object.
|
||||
@@ -100,6 +101,7 @@ def schedule(func, *args, **kwargs):
|
||||
repeats = kwargs.pop("repeats", -1)
|
||||
next_run = kwargs.pop("next_run", timezone.now())
|
||||
cron = kwargs.pop("cron", None)
|
||||
cluster = kwargs.pop("cluster", None)
|
||||
|
||||
# check for name duplicates instead of am unique constraint
|
||||
if name and Schedule.objects.filter(name=name).exists():
|
||||
@@ -117,6 +119,7 @@ def schedule(func, *args, **kwargs):
|
||||
repeats=repeats,
|
||||
next_run=next_run,
|
||||
cron=cron,
|
||||
cluster=cluster,
|
||||
)
|
||||
# make sure we trigger validation
|
||||
s.full_clean()
|
||||
|
||||
Reference in New Issue
Block a user