skip to Main Content

I want to use Сelere with Redis as backend, I’ll have a process that create tasks, stores ids and then runs again and checks statuses.
How to clear results and statuses that I don’t need anymore, could I restrict time Сelery stores result ?
Like this:

task_id = task.apply_async().id
store_id(task_id) # my code, doesn't relate to celery

Then I will get tasks and check statuses:

task_id = get_id() # my code, doesn't relate to celery
task = AsyncResult(task_id)
# do something with task
# now I don't need Celery to store this result

2

Answers


  1. Celery save the result for a day by default.

    You can however adjust this value with result_expires.

    Here are the docs.

    Default: Expire after 1 day.

    Time (in seconds, or a timedelta object)
    for when after stored task tombstones will be deleted.

    Login or Signup to reply.
  2. You can mention this in your settings.py:

    CELERY_RESULT_EXPIRES = 3600
    

    I limit the expire time to 1 hour (60 * 60 = 3,600). The default value for this is one day (86,400 seconds).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search