This reverts commit 39a22734c1.
This commit is contained in:
committed by
GitHub
parent
e5e3fcdc1c
commit
c1fe3c3a93
@@ -10,7 +10,7 @@ import os
|
||||
|
||||
from celery import Celery
|
||||
|
||||
from openedx.core.lib.celery.routers import route_task_queue
|
||||
from openedx.core.lib.celery.routers import AlternateEnvironmentRouter
|
||||
|
||||
# set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cms.envs.production')
|
||||
@@ -23,12 +23,34 @@ APP.conf.task_protocol = 1
|
||||
APP.config_from_object('django.conf:settings')
|
||||
APP.autodiscover_tasks()
|
||||
|
||||
# Import after autodiscovery has had a chance to connect to the import_module signal
|
||||
# so celery doesn't miss any apps getting installed.
|
||||
from django.conf import settings # pylint: disable=wrong-import-position,wrong-import-order
|
||||
|
||||
def route_task(name, args, kwargs, options, task=None, **kw): # pylint: disable=unused-argument
|
||||
|
||||
class Router(AlternateEnvironmentRouter):
|
||||
"""
|
||||
Celery-defined method allowing for custom routing logic.
|
||||
|
||||
If None is returned from this method, default routing logic is used.
|
||||
An implementation of AlternateEnvironmentRouter, for routing tasks to non-cms queues.
|
||||
"""
|
||||
|
||||
return route_task_queue(name)
|
||||
@property
|
||||
def alternate_env_tasks(self):
|
||||
"""
|
||||
Defines alternate environment tasks, as a dict of form { task_name: alternate_queue }
|
||||
"""
|
||||
# The tasks below will be routed to the default lms queue.
|
||||
return {
|
||||
'completion_aggregator.tasks.update_aggregators': 'lms',
|
||||
'openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache': 'lms',
|
||||
'openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache_v2': 'lms',
|
||||
}
|
||||
|
||||
@property
|
||||
def explicit_queues(self):
|
||||
"""
|
||||
Defines specific queues for tasks to run in (typically outside of the cms environment),
|
||||
as a dict of form { task_name: queue_name }.
|
||||
"""
|
||||
return {
|
||||
'lms.djangoapps.grades.tasks.compute_all_grades_for_course': settings.POLICY_CHANGE_GRADES_ROUTING_KEY,
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ def _parse_time(time_isoformat):
|
||||
).replace(tzinfo=UTC)
|
||||
|
||||
|
||||
@task
|
||||
@task(routing_key=settings.UPDATE_SEARCH_INDEX_JOB_QUEUE)
|
||||
def update_search_index(course_id, triggered_time_isoformat):
|
||||
""" Updates course search index. """
|
||||
try:
|
||||
|
||||
@@ -136,7 +136,7 @@ CELERY_QUEUES = {
|
||||
DEFAULT_PRIORITY_QUEUE: {}
|
||||
}
|
||||
|
||||
CELERY_ROUTES = "{}celery.route_task".format(QUEUE_VARIANT)
|
||||
CELERY_ROUTES = "{}celery.Router".format(QUEUE_VARIANT)
|
||||
|
||||
# STATIC_URL_BASE specifies the base url to use for static files
|
||||
STATIC_URL_BASE = ENV_TOKENS.get('STATIC_URL_BASE', None)
|
||||
@@ -567,20 +567,3 @@ if FEATURES.get('ENABLE_CORS_HEADERS'):
|
||||
CORS_ALLOW_HEADERS = corsheaders_default_headers + (
|
||||
'use-jwt-cookie',
|
||||
)
|
||||
|
||||
######################## CELERY ROTUING ########################
|
||||
|
||||
# Defines alternate environment tasks, as a dict of form { task_name: alternate_queue }
|
||||
ALTERNATE_ENV_TASKS = {
|
||||
'completion_aggregator.tasks.update_aggregators': 'lms',
|
||||
'openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache': 'lms',
|
||||
'openedx.core.djangoapps.content.block_structure.tasks.update_course_in_cache_v2': 'lms',
|
||||
}
|
||||
|
||||
# Defines the task -> alternate worker queue to be used when routing.
|
||||
EXPLICIT_QUEUES = {
|
||||
'lms.djangoapps.grades.tasks.compute_all_grades_for_course': {
|
||||
'queue': POLICY_CHANGE_GRADES_ROUTING_KEY},
|
||||
'cms.djangoapps.contentstore.tasks.update_search_index': {
|
||||
'queue': UPDATE_SEARCH_INDEX_JOB_QUEUE},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user