mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 13:08: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:
+5
-5
@@ -325,12 +325,12 @@ def monitor(result_queue, broker=None):
|
||||
save_cached(task, broker)
|
||||
else:
|
||||
save_task(task, broker)
|
||||
# acknowledge and log the result
|
||||
# acknowledge result
|
||||
ack_id = task.pop('ack_id', False)
|
||||
if ack_id and (task['success'] or task.get('ack_failure', False)):
|
||||
broker.acknowledge(ack_id)
|
||||
# log the result
|
||||
if task['success']:
|
||||
# acknowledge
|
||||
ack_id = task.pop('ack_id', False)
|
||||
if ack_id:
|
||||
broker.acknowledge(ack_id)
|
||||
# log success
|
||||
logger.info(_("Processed [{}]").format(task['name']))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user