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
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
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
Provide an API to discover the path being used to store external lock
files. Tempest will use this to set up some additional locking and to
test its own behavior. Other projects might use it for error reporting
or other purposes.
Change-Id: Iad40c67072333cc25a6d3e39d7535ff14b573504
Currently folks end up using os.chdir() (see bug listed below) as
we are not exposing the subprocess.Popen's cwd parameter. It's
better to add a cwd parameter in processutils.execute so folks
do not have to issue chdir() before and after the processutils.
execute and there's less scope for problem as documented in
the bug.
Closes-Bug: #1414530
Change-Id: Ia4c77593c0f8301e059b349290e8663614a7ccfd
This reverts commit 7c7493feb53429577efca2c4b0380af03ddc149b.
This change breaks the API of execute() and breaks nova's tests.
Closes-Bug: #1410348
Change-Id: I33fa9b4e6099f521e0de3cb4585016fd694c4548
Taskflow has a reader/writer lock that is likely useful
to other projects; and it seems better at home in this
module.
The class provides a way to create reader/writer locks
where there may be many readers at the same time (but
only one writer). It does not allow (currently) for privilege
escalation (but this could be added with limited support
in the future).
Change-Id: Ie763ef92f31c34869d83a533bc8761b0fbd77217
Add encoding and errors parameters to execute() and ssh_execute(). By
default, use the locale encoding in strict mode on Python 2, or the
locale encoding with the 'surrogateescape' error handler on Python 3.
Fix also unit tests to use bytes strings for stdin, stdout and stderr.
Without this change, tests are failing with Python 3 when run with:
PYTHON="python -bb" testr run
Using -bb, Python 3 raises a TypeError when a bytes string is casted
to a text string, which occurred in many places.
Change-Id: I655d5abf932c9a104e3ab487e23c372377f7096a
It can be undesirable to have a globally shared sempahore
container, especially since oslo.concurrency can now be shared
among many disjoint applications and libraries.
When a single container is used it is now possible to have those
disjoint applications/libraries collide on the same sempahore names.
This is not a good pattern to continue with, so in order to move away
from it allow a custom container to be provided (which defaults to the
existing global one) so that users of oslo.concurrency may provide there
own container if they so desire.
Change-Id: I9aab42e21ba0f52997de3e7c9b0fea51db5c7289
Move the public API out of oslo.concurrency to oslo_concurrency. Retain
the ability to import from the old namespace package for backwards
compatibility for this release cycle.
bp/drop-namespace-packages
Change-Id: I20d1647b1c3ef8cab3b69eccfe168eeb01703b72