diff options
| author | James Cammarata <jimi@sngx.net> | 2016-09-16 00:14:53 -0500 |
|---|---|---|
| committer | James Cammarata <jimi@sngx.net> | 2016-09-17 08:12:52 -0500 |
| commit | 5a57c66e3c14e26fa5f20f1ce9bb038c667b19e5 (patch) | |
| tree | 465666889713c1e17a84ae9804d373b52f2ca240 /lib/ansible/executor/action_write_locks.py | |
| parent | dfb1c0647e907dd27509922da995932dcc6be8db (diff) | |
| download | ansible-threaded_receiver.tar.gz | |
Moving result reading to a background threadthreaded_receiver
Diffstat (limited to 'lib/ansible/executor/action_write_locks.py')
| -rw-r--r-- | lib/ansible/executor/action_write_locks.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ansible/executor/action_write_locks.py b/lib/ansible/executor/action_write_locks.py new file mode 100644 index 0000000000..413d56d9d7 --- /dev/null +++ b/lib/ansible/executor/action_write_locks.py @@ -0,0 +1,43 @@ +# (c) 2016 - Red Hat, Inc. <support@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from multiprocessing import Lock +from ansible.module_utils.facts import Facts + +if 'action_write_locks' not in globals(): + # Do not initialize this more than once because it seems to bash + # the existing one. multiprocessing must be reloading the module + # when it forks? + action_write_locks = dict() + + # Below is a Lock for use when we weren't expecting a named module. + # 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() + + # 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() + |
