Explorar el Código

Adds setting CELERY_IGNORE_RESULT. Enables you to set the default value for Task.ignore_result.

Ask Solem hace 15 años
padre
commit
49b864e596
Se han modificado 3 ficheros con 10 adiciones y 1 borrados
  1. 2 0
      celery/conf.py
  2. 1 1
      celery/task/base.py
  3. 7 0
      docs/configuration.rst

+ 2 - 0
celery/conf.py

@@ -16,6 +16,7 @@ _DEFAULTS = {
     "CELERY_ALWAYS_EAGER": False,
     "CELERY_TASK_RESULT_EXPIRES": timedelta(days=5),
     "CELERY_SEND_EVENTS": False,
+    "CELERY_IGNORE_RESULT": False,
     "CELERY_STORE_ERRORS_EVEN_IF_IGNORED": False,
     "CELERY_TASK_SERIALIZER": "pickle",
     "CELERY_DISABLE_RATE_LIMITS": False,
@@ -66,6 +67,7 @@ CELERY_BACKEND = _get("CELERY_BACKEND")
 CELERY_CACHE_BACKEND = _get("CELERY_CACHE_BACKEND")
 TASK_SERIALIZER = _get("CELERY_TASK_SERIALIZER")
 TASK_RESULT_EXPIRES = _get("CELERY_TASK_RESULT_EXPIRES")
+IGNORE_RESULT = _get("CELERY_IGNORE_RESULT")
 # Make sure TASK_RESULT_EXPIRES is a timedelta.
 if isinstance(TASK_RESULT_EXPIRES, int):
     TASK_RESULT_EXPIRES = timedelta(seconds=TASK_RESULT_EXPIRES)

+ 1 - 1
celery/task/base.py

@@ -157,7 +157,7 @@ class Task(object):
     immediate = False
     mandatory = False
     priority = None
-    ignore_result = False
+    ignore_result = conf.IGNORE_RESULT
     disable_error_emails = False
     max_retries = 3
     default_retry_delay = 3 * 60

+ 7 - 0
docs/configuration.rst

@@ -333,6 +333,13 @@ Task execution settings
     Tasks will never be sent to the queue, but executed locally
     instead.
 
+* CELERY_IGNORE_RESULT
+
+    Wheter to store the task return values or not (tombstones).
+    If you still want to store errors, just not successful return values,
+    you can set ``CELERY_STORE_ERRORS_EVEN_IF_IGNORED``.
+
+
 * CELERY_TASK_RESULT_EXPIRES
     Time (in seconds, or a :class:`datetime.timedelta` object) for when after
     stored task tombstones are deleted.