mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-12 02:51:49 -05:00
The task manager was doing work to compute currently consumed capacity, this is moved into the manager and applied in the same form to the instance group list.
38 lines
905 B
Python
38 lines
905 B
Python
|
|
# Python
|
|
import logging
|
|
|
|
# Celery
|
|
from celery import Task, task
|
|
|
|
# AWX
|
|
from awx.main.scheduler import TaskManager
|
|
|
|
logger = logging.getLogger('awx.main.scheduler')
|
|
|
|
# TODO: move logic to UnifiedJob model and use bind=True feature of celery.
|
|
# Would we need the request loop then? I think so. Even if we get the in-memory
|
|
# updated model, the call to schedule() may get stale data.
|
|
|
|
|
|
class LogErrorsTask(Task):
|
|
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
|
logger.exception('Task {} encountered exception.'.format(self.name), exc_info=exc)
|
|
super(LogErrorsTask, self).on_failure(exc, task_id, args, kwargs, einfo)
|
|
|
|
|
|
@task
|
|
def run_job_launch(job_id):
|
|
TaskManager().schedule()
|
|
|
|
|
|
@task
|
|
def run_job_complete(job_id):
|
|
TaskManager().schedule()
|
|
|
|
|
|
@task(base=LogErrorsTask)
|
|
def run_task_manager():
|
|
logger.debug("Running Tower task manager.")
|
|
TaskManager().schedule()
|