Commit f379a4b1 by Will Daly

Put rescheduling tasks on the low-priority queue

parent 8f9dd4c8
......@@ -5,6 +5,7 @@ Asynchronous tasks for grading essays using text classifiers.
import datetime
from celery import task
from django.db import DatabaseError
from django.conf import settings
from celery.utils.log import get_task_logger
from dogapi import dog_stats_api
from openassessment.assessment.api import ai_worker as ai_worker_api
......@@ -17,6 +18,10 @@ MAX_RETRIES = 2
logger = get_task_logger(__name__)
# If the Django settings define a low-priority queue, use that.
# Otherwise, use the default queue.
RESCHEDULE_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
@task(max_retries=MAX_RETRIES) # pylint: disable=E1102
def grade_essay(workflow_uuid):
......@@ -93,7 +98,7 @@ def grade_essay(workflow_uuid):
raise grade_essay.retry()
@task(max_retries=MAX_RETRIES) # pylint: disable=E1102
@task(queue=RESCHEDULE_TASK_QUEUE, max_retries=MAX_RETRIES) # pylint: disable=E1102
def reschedule_grading_tasks(course_id, item_id):
"""
Reschedules all incomplete grading workflows with the specified parameters.
......@@ -243,4 +248,4 @@ def _log_complete_reschedule_grading(course_id=None, item_id=None, seconds=-1, s
if not success:
msg += u" At least one grading task failed due to internal error."
msg.format(cid=course_id,iid=item_id,s=seconds)
logger.info(msg)
\ No newline at end of file
logger.info(msg)
......@@ -22,6 +22,8 @@ logger = get_task_logger(__name__)
# If the Django settings define a low-priority queue, use that.
# Otherwise, use the default queue.
TRAINING_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
RESCHEDULE_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
class InvalidExample(Exception):
"""
......@@ -146,7 +148,7 @@ def train_classifiers(workflow_uuid):
raise
@task(max_retries=MAX_RETRIES) #pylint: disable E=1102
@task(queue=RESCHEDULE_TASK_QUEUE, max_retries=MAX_RETRIES) #pylint: disable=E1102
def reschedule_training_tasks(course_id, item_id):
"""
Reschedules all incomplete training tasks
......@@ -281,4 +283,4 @@ def _log_complete_reschedule_training(course_id=None, item_id=None, seconds=-1,
if not success:
msg += u" At least one rescheduling task failed due to internal error."
msg.format(cid=course_id,iid=item_id,s=seconds)
logger.info(msg)
\ No newline at end of file
logger.info(msg)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment