Query database running tasks after querying celery to prevent race

condition that could cause us to think the task was orphaned
This commit is contained in:
Matthew Jones 2014-08-12 10:34:52 -04:00
parent aac6cc6a5a
commit 6dae240849

View File

@ -142,9 +142,6 @@ def get_tasks():
def rebuild_graph(message):
''' Regenerate the task graph by refreshing known tasks from Tower, purging orphaned running tasks,
and creatingdependencies for new tasks before generating directed edge relationships between those tasks '''
all_sorted_tasks = get_tasks()
if not len(all_sorted_tasks):
return None
inspector = inspect()
if not hasattr(settings, 'IGNORE_CELERY_INSPECTOR'):
@ -153,6 +150,10 @@ def rebuild_graph(message):
print("Ignoring celery task inspector")
active_task_queues = None
all_sorted_tasks = get_tasks()
if not len(all_sorted_tasks):
return None
active_tasks = []
if active_task_queues is not None:
for queue in active_task_queues: