If the user specifies preexec_fn, we should call that in
our existing _subprocess_setup. On windows, we silently
drop this preexec_fn as subprocess.Popen raises a ValueError
if we do pass it in.
Change-Id: I0176c66fa2de001aa14f0d928d06fd894de55511
If the subprocess.Popen.communicate method raises an exception,
the on_completion callback is never invoked. If a caller is
trying to use on_execute + on_completion to track lifecycle
of a process this creates a problem, as they cannot reliably
detect completion.
Change-Id: I22b2d7bde8797276f7670bc289d915dab5122481
Closes-bug: #1470868
This object is just another thread and its cancel method
does not join on itself, so we should make sure that we do
to avoid leaving threads lying around.
Change-Id: I37e3170b58627dee93513ec222f9a55001389dad
To ensure we show accurate timing information about
lock acqusition and release times use a timing mechanism
which can not/should not move backwards.
Change-Id: I9559b20cf7de67fc474e6e17eda23791ecc4122e
Add optional on_execute and on_completion callbacks to allow callers of
procesutils.execute() to track process completion asynchronously.
This could be used to cache the pid of long running tasks associated
with an instance and then clear the cache when the process completes.
While the tasks are running should it be required the pid retrieved and
the process can be signaled.
Co-Authored-By: abhishekkekane <abhishek.kekane@nttdata.com>
Change-Id: Ifc23325eddb523f6449ba06a2deb0885a8a7009d
The fasteners library (extracted from this library and a couple other
variations) provides the interprocess lock logic and the reader writer
lock logic so we can remove the local version and we can just use it
from that library instead.
The tests that were ensuring the internals of this file lock have
now moved to the repo where that library is (for the time being),
currently travis is testing that repo against py2.6, py2.7 and py3.4.
https://github.com/harlowja/fasteners/tree/master/fasteners/tests
Docs also exist at:
http://fasteners.readthedocs.org/en/latest/
Change-Id: I98565b22e68358efe28fea62f74f8ebfcc438ff7
Copy fileutils.py changes from change id(s):
I369226f619895299c62f22a1debd0d4d120c912d
I7decb7bf5f3185f7d26ad99b0cb3475a88d3ec99
Also fix the openstack-common.conf to the correct package name
Change-Id: Ic77262bf94408395e720490264bcf7022461fe4d
Add an optional binary parameter to execute() and ssh_execute()
functions of oslo_concurrency.processutils. If binary is True, stdout
and stderr are returned as byte strings on Python 2 and Python 3.
When Nova will be ported to Python 3, binary=True will be needed to get
binary outputs (like an encryption key, see the bug #1410348).
Add new tests.
This changeset does not change the default behaviour.
Change-Id: I283cadf04781942b65f211237070cc2354939cdb
Related-Bug: 1410348
On Python 3, execute() and ssh_execute() now return stdout and stderr as
Unicode. os.fsdecode() is used to stdout and stderr, it uses the locale
encoding with the surrogateescape error handler.
subprocess.Popen(universal_encoding=True) uses the same encoding and
error handler.
This change breaks the backward compatibility, but I believe that
Unicode is more convinient in Python 3 and it is what users expect. In
practice, there is no known (OpenStack) application compatible with
Python 3 using oslo_concurrency.processutils yet.
Add new tests.
This changeset does not change the behaviour on Python 2, only Python 3
is impacted.
Change-Id: Ibb510642c1440e2fbe7ad53d797bc7c32a3cbddf
While using docker to test this module, I discovered that the
test suite does not pass because the processutils.execute() code
will not prepend the root helper because it already has root
permissions, which results in the shell trying to execute the
command 'a b c', rather than 'echo a b c'.
Change-Id: Id3429f06d6a0353f1cc4520af6daceed48c30071
Also makes the docs look more like the other
oslo libraries so that the content is easily readable
across projects.
Change-Id: I7b048bc4425197f87436281dd5e46619390c3f43