Browse Source

max_retries can now be None, which means it will retry forever.

Ask Solem 15 years ago
parent
commit
0f079e2b71
1 changed files with 3 additions and 1 deletions
  1. 3 1
      celery/task/base.py

+ 3 - 1
celery/task/base.py

@@ -112,6 +112,7 @@ class Task(object):
     .. attribute:: max_retries
     .. attribute:: max_retries
 
 
         Maximum number of retries before giving up.
         Maximum number of retries before giving up.
+        If set to ``None``, it will never stop retrying.
 
 
     .. attribute:: default_retry_delay
     .. attribute:: default_retry_delay
 
 
@@ -348,7 +349,8 @@ class Task(object):
         max_exc = exc or self.MaxRetriesExceededError(
         max_exc = exc or self.MaxRetriesExceededError(
                 "Can't retry %s[%s] args:%s kwargs:%s" % (
                 "Can't retry %s[%s] args:%s kwargs:%s" % (
                     self.name, options["task_id"], args, kwargs))
                     self.name, options["task_id"], args, kwargs))
-        if options["retries"] > self.max_retries:
+        max_retries = self.max_retries
+        if max_retries is not None and options["retries"] > max_retries:
             raise max_exc
             raise max_exc
 
 
         # If task was executed eagerly using apply(),
         # If task was executed eagerly using apply(),