Commit 74051ae1 authored by Raphaël Hertzog's avatar Raphaël Hertzog

tasks: log a specific message when a task is skipped due to failed locking

parent e328fdd7
......@@ -375,6 +375,10 @@ def run_task(task, *args, **kwargs):
logger.info("Starting task %s", task.task_name())
try:
task.execute()
except task.LockError:
logger.info("Task %s has been skipped due to its run lock",
task.task_name())
return False
except Exception:
logger.exception("Task %s failed with the following traceback.",
task.task_name())
......
......@@ -669,6 +669,18 @@ class TaskUtilsTests(TestCase):
result = run_task(TestRunTask)
self.assertFalse(result)
def test_run_task_with_lock_error(self):
task_data = TaskData.objects.create(task_name='test_run_task')
self.assertTrue(task_data.get_run_lock())
with self.assertLogs('distro_tracker.tasks') as cm:
result = run_task(TestRunTask)
msg = 'Task test_run_task has been skipped due to its run lock'
self.assertIn('INFO:distro_tracker.tasks:%s' % msg, cm.output)
self.assertFalse(result)
self.assertEqual(len(TestRunTask.executed), 0)
def test_build_all_tasks_returns_a_dict_of_all_tasks(self):
result = build_all_tasks()
......
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