Working Redis, but need to switch out ZeroMQ.

This commit is contained in:
Luke Sneeringer 2014-10-27 13:24:24 -05:00
parent 4eb1eb8036
commit f4efbfc95a
3 changed files with 28 additions and 8 deletions

View File

@ -727,7 +727,9 @@ class ProjectUpdateView(GenericAPIView):
return Response({}, status=status.HTTP_400_BAD_REQUEST)
else:
headers = {'Location': project_update.get_absolute_url()}
return Response(dict(project_update=project_update.id), status=status.HTTP_202_ACCEPTED, headers=headers)
return Response({'project_update': project_update.id},
headers=headers,
status=status.HTTP_202_ACCEPTED)
else:
return self.http_method_not_allowed(request, *args, **kwargs)

View File

@ -674,24 +674,41 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
return True
def signal_start(self, **kwargs):
'''
Notify the task runner system to begin work on this task.
'''
from awx.main.tasks import notify_task_runner
"""Notify the task runner system to begin work on this task."""
# Sanity check: If we are running unit tests, then run synchronously.
if getattr(settings, 'CELERY_UNIT_TEST', False):
return self.start(None, **kwargs)
# Sanity check: Are we able to start the job? If not, do not attempt
# to do so.
if not self.can_start:
return False
# Get any passwords or other data that are prerequisites to running
# the job.
needed = self.get_passwords_needed_to_start()
opts = dict([(field, kwargs.get(field, '')) for field in needed])
if not all(opts.values()):
return False
extra_data = dict([(field, kwargs[field]) for field in kwargs if field not in needed])
extra_data = dict([(field, kwargs[field]) for field in kwargs
if field not in needed])
self.handle_extra_data(extra_data)
# Save the pending status, and inform the SocketIO listener.
self.update_fields(start_args=json.dumps(kwargs), status='pending')
self.socketio_emit_status("pending")
# Each type of unified job has a different Task class; get the
# appropirate one.
task_type = get_type_for_model(self)
# notify_task_runner.delay(dict(task_type=task_type, id=self.id, metadata=kwargs))
# Actually tell the task runner to run this task.
from awx.main.tasks import notify_task_runner
notify_task_runner.delay({'id': self.id, 'metadata': kwargs,
'task_type': task_type})
# Done!
return True
@property

View File

@ -112,7 +112,8 @@ def notify_task_runner(metadata_dict):
@task(bind=True)
def handle_work_error(self, task_id, subtasks=None):
print('Executing error task id %s, subtasks: %s' % (str(self.request.id), str(subtasks)))
print('Executing error task id %s, subtasks: %s' %
(str(self.request.id), str(subtasks)))
first_task = None
first_task_type = ''
first_task_name = ''