Retry when trying to store a Celery result in backend

Adds retry logic when attempting to store a Celery result in the
backend. If it fails the behavior is to exponentially (from 10ms to 10s)
backoff.

For more context on why this was implemented see:
https://github.com/celery/celery/pull/6122
This commit is contained in:
Dani Hodovic 2022-12-12 14:19:12 +01:00
parent e8b9253c0b
commit 33b60f5df2
No known key found for this signature in database
GPG Key ID: 15433E10A71D1221

View File

@ -283,6 +283,11 @@ if USE_TZ:
CELERY_BROKER_URL = env("CELERY_BROKER_URL")
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
# https://github.com/celery/celery/pull/6122
CELERY_RESULT_BACKEND_ALWAYS_RETRY = True
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-max-retries
CELERY_RESULT_BACKEND_MAX_RETRIES = 10
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-accept_content
CELERY_ACCEPT_CONTENT = ["json"]
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-task_serializer