1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Fix up run task manager script to handle signals, fix up task cancel job, add restart handler for ubuntu

This commit is contained in:
Matthew Jones 2014-03-17 11:05:53 -04:00
parent 28c9d77f29
commit f6ac7fb6d0
2 changed files with 13 additions and 5 deletions

View File

@ -188,7 +188,7 @@ def rebuild_graph(message):
dep.status = 'waiting'
dep.save()
waiting_tasks.insert(waiting_tasks.index(task), dep)
#if not hasattr(settings, 'CELERY_UNIT_TEST'):
if not hasattr(settings, 'UNIT_TEST_IGNORE_TASK_WAIT'):
task.status = 'waiting'
task.save()
@ -248,6 +248,13 @@ def process_graph(graph, task_capacity):
def run_taskmanager(command_port):
''' Receive task start and finish signals to rebuild a dependency graph and manage the actual running of tasks '''
def shutdown_handler():
def _handler(signum, frame):
signal.signal(signum, signal.SIG_DFL)
os.kill(os.getpid(), signum)
return _handler
signal.signal(signal.SIGINT, shutdown_handler())
signal.signal(signal.SIGTERM, shutdown_handler())
paused = False
task_capacity = get_system_task_capacity()
command_context = zmq.Context()

View File

@ -646,10 +646,11 @@ class RunJobTest(BaseCeleryTest):
self.assertFalse(job.cancel())
self.assertEqual(job.cancel_flag, False)
self.assertFalse(job.passwords_needed_to_start)
self.build_args_callback = self._cancel_job_callback
job.cancel_flag = True
job.save()
self.assertTrue(job.signal_start())
job = Job.objects.get(pk=job.pk)
self.check_job_result(job, 'canceled')
self.check_job_result(job, 'canceled', expect_stdout=False)
self.assertEqual(job.cancel_flag, True)
# Calling cancel afterwards just returns the cancel flag.
self.assertTrue(job.cancel())