ansible.plugins.strategy.StrategyBase._results_lock is acquired to control access to StrategyBase._results and StrategyBase._handler_results. Specifically
in ansible.plugins.strategy.results_thread_main() before append() ing a result
in StrategyBase_process_pending_results() before popleft() ing
However StrategyBase._results & _handler_results are both collections.deque objects. From the Python docs
Deques support thread-safe, memory efficient appends and pops from either side of the deque.
Thus AFAICT the lock isn’t needed for the deque operations, and could possibly be removed. Have I missed something? Is the lock providing another protection I’ve not noticed? Is it there as a belt and braces measure?
If there’s no reason to have it, and interest in removing it, I’ll submit a PR. Alternatively maybe there’s benefit in keeping the lock and using wait()/notify() instead of some of the polling.
only handlers have the listen attr, so this must be a handler
we split up the results into two queues here to make sure
handler and regular result processing don’t cross wires
if ‘listen’ in result._task_fields:
strategy._handler_results.append(result)
else:
strategy._results.append(result)
only handlers have the listen attr, so this must be a handler
we split up the results into two queues here to make sure
handler and regular result processing don’t cross wires
if ‘listen’ in result._task_fields:
strategy._handler_results.append(result)
else:
strategy._results.append(result)
else:
display.warning(‘Received an invalid object (%s) in the result queue: %r’ % (type(result), result))
except (IOError, EOFError):
@@ -223,7 +222,6 @@ class StrategyBase: