From fa856d333882bc3af953aecf9271f8517535b58c Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Mon, 6 Jan 2014 13:32:32 -0500 Subject: [PATCH] Logging to catch duplicate instructor tasks --- lms/djangoapps/instructor_task/api_helper.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lms/djangoapps/instructor_task/api_helper.py b/lms/djangoapps/instructor_task/api_helper.py index 37a9852caa..606907cdae 100644 --- a/lms/djangoapps/instructor_task/api_helper.py +++ b/lms/djangoapps/instructor_task/api_helper.py @@ -52,8 +52,21 @@ def _reserve_task(course_id, task_type, task_key, task_input, requester): """ if _task_is_running(course_id, task_type, task_key): + log.warning("Duplicate task found for task_type %s and task_key %s", task_type, task_key) raise AlreadyRunningError("requested task is already running") + try: + most_recent_id = InstructorTask.objects.latest('id').id + except InstructorTask.DoesNotExist: + most_recent_id = "None found" + finally: + log.warning( + "No duplicate tasks found: task_type %s, task_key %s, and most recent task_id = %s", + task_type, + task_key, + most_recent_id + ) + # Create log entry now, so that future requests will know it's running. return InstructorTask.create(course_id, task_type, task_key, task_input, requester)