Make sure registered variable message is sent before other messages

Avoids a race condition where previously the registered variable message
was being sent after the 'host_task_ok' message, meaning the next task
may be started before the var is registered, leading to an undefined
variable error
This commit is contained in:
James Cammarata 2015-06-17 12:42:47 -04:00
parent 8cfec0a27a
commit daa319881f

View file

@ -105,7 +105,9 @@ class ResultProcess(multiprocessing.Process):
time.sleep(0.1)
continue
host_name = result._host.get_name()
# if this task is registering a result, do it now
if result._task.register:
self._send_result(('set_host_var', result._host, result._task.register, result._result))
# send callbacks, execute other options based on the result status
# FIXME: this should all be cleaned up and probably moved to a sub-function.
@ -160,10 +162,6 @@ class ResultProcess(multiprocessing.Process):
# finally, send the ok for this task
self._send_result(('host_task_ok', result))
# if this task is registering a result, do it now
if result._task.register:
self._send_result(('set_host_var', result._host, result._task.register, result._result))
except queue.Empty:
pass
except (KeyboardInterrupt, IOError, EOFError):