Skip to content

Commit

Permalink
Merge pull request #7528 from gitcoinco/kevin/celery_routes
Browse files Browse the repository at this point in the history
MVP of celery task routing
  • Loading branch information
owocki authored Sep 24, 2020
2 parents 7ceaa02 + 1a7c3fe commit 1c45d08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/taskapp/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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}

0 comments on commit 1c45d08

Please sign in to comment.