From 394f7e408fcec85027ff245874e3fc039df6e055 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Wed, 23 Jun 2021 14:13:04 +0930 Subject: [PATCH] feat: adds CELERY_BROKER_TRANSPORT_OPTIONS which can be configured from the lms/studio environment refactor: raise ImproperlyConfigured on TypeError Signed-off-by: Gabor Boros --- cms/envs/production.py | 12 ++++++++---- lms/envs/production.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cms/envs/production.py b/cms/envs/production.py index b268b461cdce..471c00e5533f 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -391,10 +391,14 @@ def get_env_setting(setting): CELERY_BROKER_VHOST) BROKER_USE_SSL = ENV_TOKENS.get('CELERY_BROKER_USE_SSL', False) -BROKER_TRANSPORT_OPTIONS = { - 'fanout_patterns': True, - 'fanout_prefix': True, -} +try: + BROKER_TRANSPORT_OPTIONS = { + 'fanout_patterns': True, + 'fanout_prefix': True, + **ENV_TOKENS.get('CELERY_BROKER_TRANSPORT_OPTIONS', {}) + } +except TypeError as exc: + raise ImproperlyConfigured('CELERY_BROKER_TRANSPORT_OPTIONS must be a dict') from exc # Message expiry time in seconds CELERY_EVENT_QUEUE_TTL = ENV_TOKENS.get('CELERY_EVENT_QUEUE_TTL', None) diff --git a/lms/envs/production.py b/lms/envs/production.py index 3c389c5c12f5..0b1a33b7c70c 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -506,10 +506,14 @@ def get_env_setting(setting): CELERY_BROKER_VHOST) BROKER_USE_SSL = ENV_TOKENS.get('CELERY_BROKER_USE_SSL', False) -BROKER_TRANSPORT_OPTIONS = { - 'fanout_patterns': True, - 'fanout_prefix': True, -} +try: + BROKER_TRANSPORT_OPTIONS = { + 'fanout_patterns': True, + 'fanout_prefix': True, + **ENV_TOKENS.get('CELERY_BROKER_TRANSPORT_OPTIONS', {}) + } +except TypeError as exc: + raise ImproperlyConfigured('CELERY_BROKER_TRANSPORT_OPTIONS must be a dict') from exc # Block Structures