Skip to content
Snippets Groups Projects
Unverified Commit d26a59eb authored by Muhammad Soban Javed's avatar Muhammad Soban Javed Committed by GitHub
Browse files

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
parent 2723e0e2
No related branches found
Tags release-2018-12-12-12.20
No related merge requests found
......@@ -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):
......
......@@ -3,7 +3,7 @@ This file contains celery tasks for entitlements-related functionality.
"""
from celery import task
from celery import shared_task
from celery.utils.log import get_task_logger
from django.conf import settings
from edx_django_utils.monitoring import set_code_owner_attribute
......@@ -19,7 +19,7 @@ LOGGER = get_task_logger(__name__)
MAX_RETRIES = 11
@task(
@shared_task(
bind=True,
ignore_result=True,
name='entitlements.expire_old_entitlements',
......
......@@ -6,7 +6,7 @@ This file contains celery tasks for sending email
import logging
from celery.exceptions import MaxRetriesExceededError
from celery.task import task
from celery import shared_task
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
......@@ -20,7 +20,7 @@ from openedx.core.lib.celery.task_utils import emulate_http_request
log = logging.getLogger('edx.celery.task')
@task(bind=True, name='student.send_activation_email')
@shared_task(bind=True, name='student.send_activation_email')
@set_code_owner_attribute
def send_activation_email(self, msg_string, from_address=None):
"""
......
......@@ -10,7 +10,7 @@ import logging
import dateutil.parser
import pytz
import requests
from celery.task import task
from celery import shared_task
from django.utils.timezone import now
from edx_django_utils.monitoring import set_code_owner_attribute
from lxml import etree
......@@ -31,7 +31,7 @@ class MetadataParseError(Exception):
pass
@task(name='third_party_auth.fetch_saml_metadata')
@shared_task(name='third_party_auth.fetch_saml_metadata')
@set_code_owner_attribute
def fetch_saml_metadata():
"""
......
......@@ -138,7 +138,7 @@ class SignalHandler(object):
To listen for a signal, do the following::
from django.dispatch import receiver
from celery.task import task
from celery import shared_task
from edx_django_utils.monitoring import set_code_owner_attribute
from xmodule.modulestore.django import modulestore, SignalHandler
......@@ -146,7 +146,7 @@ class SignalHandler(object):
def listen_for_course_publish(sender, course_key, **kwargs):
do_my_expensive_update.delay(course_key)
@task()
@shared_task()
@set_code_owner_attribute
def do_my_expensive_update(course_key):
# ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment