diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py index 875380e..d4690f9 100644 --- a/lib/ansible/executor/module_common.py +++ b/lib/ansible/executor/module_common.py @@ -34,10 +34,10 @@ from ansible.release import __version__, __author__ from ansible import constants as C from ansible.errors import AnsibleError from ansible.utils.unicode import to_bytes, to_unicode -# Must import strategy and use write_locks from there -# If we import write_locks directly then we end up binding a +# Must import strategy and use task_queue_manager from there +# If we import task_queue_manager directly then we end up binding a # variable to the object and then it never gets updated. -from ansible.executor.task_queue_manager import action_write_locks +from ansible.executor import task_queue_manager try: from __main__ import display @@ -575,16 +575,16 @@ def _find_snippet_imports(module_name, module_data, module_path, module_args, ta display.debug('ANSIBALLZ: using cached module: %s' % cached_module_filename) zipdata = open(cached_module_filename, 'rb').read() else: - if module_name in action_write_locks: + if module_name in task_queue_manager.action_write_locks: display.debug('ANSIBALLZ: Using lock for %s' % module_name) - lock = action_write_locks[module_name] + lock = task_queue_manager.action_write_locks[module_name] else: # If the action plugin directly invokes the module (instead of # going through a strategy) then we don't have a cross-process # Lock specifically for this module. Use the "unexpected # module" lock instead display.debug('ANSIBALLZ: Using generic lock for %s' % module_name) - lock = action_write_locks[None] + lock = task_queue_manager.action_write_locks[None] display.debug('ANSIBALLZ: Acquiring lock') with lock: diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 14c0026..2de8fb3 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -62,14 +62,14 @@ if 'action_write_locks' not in globals(): # It gets used when an action plugin directly invokes a module instead # of going through the strategies. Slightly less efficient as all # processes with unexpected module names will wait on this lock - action_write_locks[None] = Lock() + action_write_locks[None] = multiprocessing.Lock() # These plugins are called directly by action plugins (not going through # a strategy). We precreate them here as an optimization mods = set(p['name'] for p in Facts.PKG_MGRS) mods.update(('copy', 'file', 'setup', 'slurp', 'stat')) for mod_name in mods: - action_write_locks[mod_name] = Lock() + action_write_locks[mod_name] = multiprocessing.Lock() # TODO: this should probably be in the plugins/__init__.py, with # a smarter mechanism to set all of the attributes based on @@ -182,7 +182,7 @@ class TaskQueueManager: if task.action not in action_write_locks: display.debug('Creating lock for %s' % task.action) - action_write_locks[task.action] = Lock() + action_write_locks[task.action] = multiprocessing.Lock() try: #task_vars = self._variable_manager.get_vars(loader=self._loader, play=self._iterator._play, host=host, task=task)