From 2175d00b83941b098dae82358e997cb46b600332 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 29 Oct 2020 10:52:16 -0400 Subject: [PATCH] Update celery task discovery config. (#25479) Update the celery startup code to more closely match the docs. We believe some of these imports are causeing circulare dependencies that are causing race conditions in task discovery. Since all django apps should be loaded using the django fixup in celery 4, we shouldn't need these other overrides. https://github.com/celery/celery/blob/v4.4.7/celery/fixups/django.py https://docs.celeryproject.org/en/v4.4.7/django/first-steps-with-django.html#using-celery-with-django --- cms/celery.py | 1 - cms/envs/common.py | 7 ------- lms/celery.py | 3 +-- lms/envs/common.py | 9 --------- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/cms/celery.py b/cms/celery.py index 6e1db257b3..3184dc6565 100644 --- a/cms/celery.py +++ b/cms/celery.py @@ -9,7 +9,6 @@ Taken from: https://celery.readthedocs.org/en/latest/django/first-steps-with-dja import os from celery import Celery -from django.conf import settings from openedx.core.lib.celery.routers import AlternateEnvironmentRouter diff --git a/cms/envs/common.py b/cms/envs/common.py index 1c29f6d23f..96adfb0319 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1213,13 +1213,6 @@ WEBPACK_CONFIG_PATH = 'webpack.prod.config.js' ################################# CELERY ###################################### -# Auto discover tasks fails to detect contentstore tasks -CELERY_IMPORTS = ( - 'cms.djangoapps.contentstore.tasks', - 'openedx.core.djangoapps.bookmarks.tasks', - 'openedx.core.djangoapps.ccxcon.tasks', -) - # Message configuration CELERY_TASK_SERIALIZER = 'json' diff --git a/lms/celery.py b/lms/celery.py index a8f0fce6e1..dd9a23a8cf 100644 --- a/lms/celery.py +++ b/lms/celery.py @@ -9,12 +9,11 @@ Taken from: https://celery.readthedocs.org/en/latest/django/first-steps-with-dja import os from celery import Celery -from django.conf import settings from openedx.core.lib.celery.routers import AlternateEnvironmentRouter # set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lms.envs.production') APP = Celery('proj') diff --git a/lms/envs/common.py b/lms/envs/common.py index cf147b1876..d5a1f21ded 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2230,15 +2230,6 @@ DEBUG_TOOLBAR_PATCH_SETTINGS = False ################################# CELERY ###################################### -# Celery's task autodiscovery won't find tasks nested in a tasks package. -# Tasks are only registered when the module they are defined in is imported. -CELERY_IMPORTS = ( - 'poll.tasks', - 'lms.djangoapps.instructor_task.tasks', - 'lms.djangoapps.bulk_email.tasks', - 'openedx.core.djangoapps.bookmarks.tasks', -) - # Message configuration CELERY_TASK_SERIALIZER = 'json'