Introduce a connection locking infrastructure

The lock file is (a temporary file) opened in the parent process, whose
open fd is inherited by the workers after fork, and passed down through
the PlayContext. Connection grows lock/unlock methods which can be used
by individual connection plugins.
This commit is contained in:
Abhijit Menon-Sen 2015-08-01 09:26:07 +05:30
parent 88d3751c28
commit 5887e96b27
3 changed files with 21 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import multiprocessing
import os
import socket
import sys
import tempfile
from ansible import constants as C
from ansible.errors import AnsibleError
@ -78,6 +79,10 @@ class TaskQueueManager:
self._failed_hosts = dict()
self._unreachable_hosts = dict()
# A temporary file (opened pre-fork) used by connection plugins for
# inter-process locking.
self._options.connection_lockfile = tempfile.TemporaryFile()
self._final_q = multiprocessing.Queue()
# create the pool of worker threads, based on the number of forks specified