1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-28 10:55:30 +03:00

emit job status over socket after database commit

* Wait until the newly created job record hits the database before
telling the websocket clients that the job's status is "pending"
This commit is contained in:
Chris Meyers 2017-02-28 12:39:55 -05:00
parent cdb757503e
commit 7da52c8bef

View File

@ -964,10 +964,13 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
# Save the pending status, and inform the SocketIO listener.
self.update_fields(start_args=json.dumps(kwargs), status='pending')
self.websocket_emit_status("pending")
def post_commit():
from awx.main.scheduler.tasks import run_job_launch
connection.on_commit(lambda: run_job_launch.delay(self.id))
self.websocket_emit_status("pending")
run_job_launch.delay(self.id)
connection.on_commit(post_commit)
# Each type of unified job has a different Task class; get the
# appropirate one.