Commit daa31988 by James Cammarata

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
parent 8cfec0a2
...@@ -105,7 +105,9 @@ class ResultProcess(multiprocessing.Process): ...@@ -105,7 +105,9 @@ class ResultProcess(multiprocessing.Process):
time.sleep(0.1) time.sleep(0.1)
continue 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 # send callbacks, execute other options based on the result status
# FIXME: this should all be cleaned up and probably moved to a sub-function. # FIXME: this should all be cleaned up and probably moved to a sub-function.
...@@ -160,10 +162,6 @@ class ResultProcess(multiprocessing.Process): ...@@ -160,10 +162,6 @@ class ResultProcess(multiprocessing.Process):
# finally, send the ok for this task # finally, send the ok for this task
self._send_result(('host_task_ok', result)) 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: except queue.Empty:
pass pass
except (KeyboardInterrupt, IOError, EOFError): except (KeyboardInterrupt, IOError, EOFError):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment