celerydjango-celery

Celery tasks without result write to result backend


I have some tasks which should return result, and some tasks that don't. I want to force tasks which shouldn't return result not to write anything in result backend (for example None). How can I achieve that in Celery?

For example it's my tasks:

@app.task
def taskWithResult():
    # ...code...
    return res

@app.task
def taskWithNoResult():
    # ...code without return...

And also I have special queue for some others task which also don't return any result, can I mark that queue as with tasks which mustn't write in result backend?


Solution

  • From celery document you can set ignore result flag to True. http://docs.celeryproject.org/en/latest/reference/celery.app.task.html?highlight=default_retry_delay#celery.app.task.Task.ignore_result

    For example:

    @app.task(ignore_result=True)
    def taskWithNoResult():
        # ...code without return..