import task decorator from celery APP instance in CMS (#25953)
* import task decorator from celery APP instance instead of celery package in CMS * replaced task decorator with shared_task in cms and common * Fixed import of shared_task * Fixed import
This commit is contained in:
committed by
GitHub
parent
2723e0e2bd
commit
d26a59eb67
@@ -5,7 +5,7 @@ Celery tasks used by cms_user_tasks
|
||||
|
||||
from boto.exception import NoAuthHandlerFound
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from celery.task import task
|
||||
from celery import shared_task
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
@@ -19,7 +19,7 @@ TASK_COMPLETE_EMAIL_MAX_RETRIES = 3
|
||||
TASK_COMPLETE_EMAIL_TIMEOUT = 60
|
||||
|
||||
|
||||
@task(bind=True)
|
||||
@shared_task(bind=True)
|
||||
@set_code_owner_attribute
|
||||
def send_task_complete_email(self, task_name, task_state_text, dest_addr, detail_url):
|
||||
"""
|
||||
|
||||
@@ -12,7 +12,7 @@ from datetime import datetime
|
||||
from tempfile import NamedTemporaryFile, mkdtemp
|
||||
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from celery.task import task
|
||||
from celery import shared_task
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
@@ -83,7 +83,7 @@ def clone_instance(instance, field_values):
|
||||
return instance
|
||||
|
||||
|
||||
@task
|
||||
@shared_task
|
||||
@set_code_owner_attribute
|
||||
def rerun_course(source_course_key_string, destination_course_key_string, user_id, fields=None):
|
||||
"""
|
||||
@@ -170,7 +170,7 @@ def _parse_time(time_isoformat):
|
||||
).replace(tzinfo=UTC)
|
||||
|
||||
|
||||
@task
|
||||
@shared_task
|
||||
@set_code_owner_attribute
|
||||
def update_search_index(course_id, triggered_time_isoformat):
|
||||
""" Updates course search index. """
|
||||
@@ -201,7 +201,7 @@ def update_search_index(course_id, triggered_time_isoformat):
|
||||
LOGGER.debug(u'Search indexing successful for complete course %s', course_id)
|
||||
|
||||
|
||||
@task
|
||||
@shared_task
|
||||
@set_code_owner_attribute
|
||||
def update_library_index(library_id, triggered_time_isoformat):
|
||||
""" Updates course search index. """
|
||||
@@ -247,7 +247,7 @@ class CourseExportTask(UserTask): # pylint: disable=abstract-method
|
||||
return u'Export of {}'.format(key)
|
||||
|
||||
|
||||
@task(base=CourseExportTask, bind=True)
|
||||
@shared_task(base=CourseExportTask, bind=True)
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because
|
||||
# the implementation of this task breaks with any additional decorators.
|
||||
def export_olx(self, user_id, course_key_string, language):
|
||||
@@ -382,7 +382,7 @@ class CourseImportTask(UserTask): # pylint: disable=abstract-method
|
||||
return u'Import of {} from {}'.format(key, filename)
|
||||
|
||||
|
||||
@task(base=CourseImportTask, bind=True)
|
||||
@shared_task(base=CourseImportTask, bind=True)
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because
|
||||
# the implementation of this task breaks with any additional decorators.
|
||||
def import_olx(self, user_id, course_key_string, archive_path, archive_name, language):
|
||||
|
||||
Reference in New Issue
Block a user