From 1a7c3fe7254d3ff94198ccb7db42460192021c17 Mon Sep 17 00:00:00 2001 From: owocki Date: Thu, 24 Sep 2020 12:53:07 -0600 Subject: [PATCH] MVP of celery task routing --- app/app/settings.py | 11 +++++++++++ app/taskapp/celery.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/app/app/settings.py b/app/app/settings.py index 53a6becbf75..c38fd57257a 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -514,6 +514,17 @@ def callback(request): CELERY_RESULT_SERIALIZER = 'json' # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend CELERY_RESULT_BACKEND = env('CELERY_RESULT_BACKEND', default=CACHEOPS_REDIS) +# https://docs.celeryproject.org/en/latest/userguide/configuration.html#std-setting-task_routes +CELERY_ROUTES = [ + ('grants.tasks.process_grant_contribution', {'queue': 'high_priority'}), + ('kudos.tasks.mint_token_request', {'queue': 'high_priority'}), + ('marketing.tasks.*', {'queue': 'marketing'}), + ('grants.tasks.*', {'queue': 'default'}), + ('chat.tasks.*', {'queue': 'default'}), + ('dashboard.tasks.*', {'queue': 'default'}), + ('townsquare.tasks.*', {'queue': 'default'}), + ('kudos.tasks.*', {'queue': 'default'}), + ] DJANGO_REDIS_IGNORE_EXCEPTIONS = env.bool('REDIS_IGNORE_EXCEPTIONS', default=True) DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS = env.bool('REDIS_LOG_IGNORED_EXCEPTIONS', default=True) diff --git a/app/taskapp/celery.py b/app/taskapp/celery.py index a212dc9ba64..fd93ac0089a 100644 --- a/app/taskapp/celery.py +++ b/app/taskapp/celery.py @@ -4,6 +4,7 @@ from celery import Celery from celery.signals import setup_logging +from django.conf import settings os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') @@ -24,3 +25,4 @@ def ready(self): app.config_from_object('django.conf:settings', namespace='CELERY') installed_apps = [app_config.name for app_config in apps.get_app_configs()] app.autodiscover_tasks(lambda: installed_apps, force=True) + app.conf.task_routes = {ele[0]: ele[1] for ele in settings.CELERY_ROUTES}