mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 04:17:36 -02:30
Push celery queue stats to memcached periodically
We'll piggyback off the task that checks for inconsistent jobs between celery and Tower itself. These are read off via /api/v1/ping
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# Python
|
||||
import logging
|
||||
import json
|
||||
|
||||
# Django
|
||||
from django.db import transaction
|
||||
@@ -12,6 +13,7 @@ from celery import task
|
||||
# AWX
|
||||
from awx.main.models import Instance
|
||||
from awx.main.scheduler import TaskManager
|
||||
from django.core.cache import cache
|
||||
|
||||
logger = logging.getLogger('awx.main.scheduler')
|
||||
|
||||
@@ -38,8 +40,8 @@ def run_fail_inconsistent_running_jobs():
|
||||
try:
|
||||
Instance.objects.select_for_update(nowait=True).all()[0]
|
||||
scheduler = TaskManager()
|
||||
active_tasks = scheduler.get_active_tasks()
|
||||
|
||||
active_task_queues, active_tasks = scheduler.get_active_tasks()
|
||||
cache.set("active_celery_tasks", json.dumps(active_task_queues))
|
||||
if active_tasks is None:
|
||||
# TODO: Failed to contact celery. We should surface this.
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user