diff --git a/django_q/cluster.py b/django_q/cluster.py index c351ee5..d8e6f27 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -497,6 +497,7 @@ def save_task(task, broker: Broker): result=task["result"], group=task.get("group"), success=task["success"], + attempt_count=1 ) except Exception as e: logger.error(e) diff --git a/django_q/migrations/0013_task_attempt_count.py b/django_q/migrations/0013_task_attempt_count.py new file mode 100644 index 0000000..30d03be --- /dev/null +++ b/django_q/migrations/0013_task_attempt_count.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-08-11 15:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_q', '0012_auto_20200702_1608'), + ] + + operations = [ + migrations.AddField( + model_name='task', + name='attempt_count', + field=models.IntegerField(default=0), + ), + ] diff --git a/docs/configure.rst b/docs/configure.rst index 16801b1..afc6aa0 100644 --- a/docs/configure.rst +++ b/docs/configure.rst @@ -75,6 +75,15 @@ ack_failures When set to ``True``, also acknowledge unsuccessful tasks. This causes failed tasks to be considered as successful deliveries, thereby removing them from the task queue. Can also be set per-task by passing the ``ack_failure`` option to :func:`async_task`. Defaults to ``False``. + +.. attempt_count: + +attempt_count +~~~~~~~~~~~~~ + +Limit the number of retries for failed tasks. Set to 0 for infinite retries. Defaults to 0 + + .. _retry: retry