update_in_cache on lms worker (#12689)
This commit "undoes"a previous hotfix, and allows a cms course_publish
signal to trigger a block_structure update_course_in_cache task, which
is run on an lms worker queue.
Changes:
-exposes ALTERNATE_QUEUE_ENVS
-adds routing layer in celery.py
-moves prior dev_with_worker settings file to devstack_with_worker
-moves course_block api functionality into openedx/core/djangoapps/content/block_structure
This commit is contained in:
@@ -87,6 +87,21 @@ CELERY_QUEUES = {
|
||||
DEFAULT_PRIORITY_QUEUE: {}
|
||||
}
|
||||
|
||||
# Setup alternate queues, to allow access to cross-process workers
|
||||
ALTERNATE_QUEUE_ENVS = os.environ.get('ALTERNATE_WORKER_QUEUES', '').split()
|
||||
ALTERNATE_QUEUES = [
|
||||
DEFAULT_PRIORITY_QUEUE.replace(QUEUE_VARIANT, alternate + '.')
|
||||
for alternate in ALTERNATE_QUEUE_ENVS
|
||||
]
|
||||
CELERY_QUEUES.update(
|
||||
{
|
||||
alternate: {}
|
||||
for alternate in ALTERNATE_QUEUES
|
||||
if alternate not in CELERY_QUEUES.keys()
|
||||
}
|
||||
)
|
||||
CELERY_ROUTES = "{}celery.Router".format(QUEUE_VARIANT)
|
||||
|
||||
############# NON-SECURE ENV CONFIG ##############################
|
||||
# Things like server locations, ports, etc.
|
||||
with open(CONFIG_ROOT / CONFIG_PREFIX + "env.json") as env_file:
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
"""
|
||||
This config file follows the dev enviroment, but adds the
|
||||
This config file follows the devstack enviroment, but adds the
|
||||
requirement of a celery worker running in the background to process
|
||||
celery tasks.
|
||||
|
||||
The worker can be executed using:
|
||||
When testing locally, run lms/cms with this settings file as well, to test queueing
|
||||
of tasks onto the appropriate workers.
|
||||
|
||||
django_admin.py celery worker
|
||||
In two separate processes on devstack:
|
||||
paver devstack studio --settings=devstack_with_worker
|
||||
./manage.py cms celery worker --settings=devstack_with_worker
|
||||
"""
|
||||
|
||||
# We intentionally define lots of variables that aren't used, and
|
||||
# want to import all variables from base settings files
|
||||
# pylint: disable=wildcard-import, unused-wildcard-import
|
||||
from cms.envs.devstack import *
|
||||
|
||||
from dev import *
|
||||
|
||||
################################# CELERY ######################################
|
||||
|
||||
# Requires a separate celery worker
|
||||
|
||||
# Require a separate celery worker
|
||||
CELERY_ALWAYS_EAGER = False
|
||||
|
||||
# Use django db as the broker and result store
|
||||
|
||||
BROKER_URL = 'django://'
|
||||
INSTALLED_APPS += ('djcelery.transport', )
|
||||
CELERY_RESULT_BACKEND = 'database'
|
||||
DJKOMBU_POLLING_INTERVAL = 1.0
|
||||
|
||||
# Disable transaction management because we are using a worker. Views
|
||||
# that request a task and wait for the result will deadlock otherwise.
|
||||
for database_name in DATABASES:
|
||||
Reference in New Issue
Block a user