mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 03:48:12 +08:00
Add option for acknowledging failed tasks (globally and per-task)
If a task fails with an exception, it is retried until it succeeds. This is contrary to what is said in the documentation: under the "Architecture" section, heading "Broker" it says that even when a task errors, it's still considered a successful delivery. Failed tasks never get acknowledged however, thereby being retried after the timeout period. See also issues #238 and #194. This patch adds an option to acknowledge failures, thereby closing issue #238. Issue #194 would require some more work. The default of this option is set to `False`, thereby maintaining backwards compatibility.
This commit is contained in:
+3
-1
@@ -20,7 +20,7 @@ from django_q.queues import Queue
|
||||
def async(func, *args, **kwargs):
|
||||
"""Queue a task for the cluster."""
|
||||
keywords = kwargs.copy()
|
||||
opt_keys = ('hook', 'group', 'save', 'sync', 'cached', 'iter_count', 'iter_cached', 'chain', 'broker')
|
||||
opt_keys = ('hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker')
|
||||
q_options = keywords.pop('q_options', {})
|
||||
# get an id
|
||||
tag = uuid()
|
||||
@@ -42,6 +42,8 @@ def async(func, *args, **kwargs):
|
||||
task['cached'] = Conf.CACHED
|
||||
if 'sync' not in task and Conf.SYNC:
|
||||
task['sync'] = Conf.SYNC
|
||||
if 'ack_failure' not in task and Conf.ACK_FAILURES:
|
||||
task['ack_failure'] = Conf.ACK_FAILURES
|
||||
# finalize
|
||||
task['kwargs'] = keywords
|
||||
task['started'] = timezone.now()
|
||||
|
||||
Reference in New Issue
Block a user