Skip to content

Commit 3e771e5

Browse files
committed
enable result backend
1 parent 45230ea commit 3e771e5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

matter_task_queue/celery_config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def format(self, record):
9090

9191
def build_celery_config(create_dead_letter_queue: bool):
9292
sqs_attributes = get_sqs_attributes() if create_dead_letter_queue else {}
93-
return {
93+
celery_config = {
9494
"broker_url": Config.CELERY_BROKER_URL,
9595
"broker_transport_options": {
9696
"region": Config.AWS_REGION,
@@ -104,13 +104,18 @@ def build_celery_config(create_dead_letter_queue: bool):
104104
),
105105
"task_routes": (route_task,),
106106
"worker_pool_restarts": True,
107-
"task_ignore_result": True,
107+
"task_ignore_result": True if not Config.CELERY_RESULT_BACKEND_URL else False,
108108
"worker_hijack_root_logger": False,
109109
"worker_enable_remote_control": False,
110110
"worker_send_task_events": False,
111111
"task_always_eager": Config.DEBUG and Config.IS_ENV_LOCAL_OR_TEST,
112112
}
113113

114+
if Config.CELERY_RESULT_BACKEND_URL:
115+
celery_config["result_backend"] = Config.CELERY_RESULT_BACKEND_URL
116+
117+
return celery_config
118+
114119

115120
CELERY_BEAT_CONFIG = {
116121
"traceback": True,

matter_task_queue/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def load_variables(cls):
1919
cls.SENTRY_DSN = os.getenv("SENTRY_DSN")
2020
cls.AWS_ENDPOINT_URL = os.getenv("AWS_ENDPOINT_URL")
2121
cls.CELERY_BROKER_URL = os.environ["CELERY_BROKER_URL"] if cls.ENV != "test" else os.getenv("CELERY_BROKER_URL")
22+
cls.CELERY_RESULT_BACKEND_URL = os.getenv("CELERY_RESULT_BACKEND_URL")
2223

2324

2425
Config()

0 commit comments

Comments
 (0)