summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.zuul.yaml2
-rw-r--r--doc/requirements.txt4
-rw-r--r--lower-constraints.txt2
-rw-r--r--oslo_concurrency/lockutils.py62
-rw-r--r--oslo_concurrency/tests/unit/test_lockutils.py9
-rw-r--r--tox.ini5
6 files changed, 70 insertions, 14 deletions
diff --git a/.zuul.yaml b/.zuul.yaml
index 9bb6ef1..e58d50f 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -6,7 +6,7 @@
- openstack-cover-jobs
- openstack-lower-constraints-jobs
- openstack-python-jobs
- - openstack-python3-train-jobs
+ - openstack-python3-ussuri-jobs
- periodic-stable-jobs
- publish-openstack-docs-pti
- release-notes-jobs-python3
diff --git a/doc/requirements.txt b/doc/requirements.txt
index 25408d9..00b94af 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -2,8 +2,8 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# this is required for the docs build jobs
-sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
-sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2;python_version>='3.4' # BSD
+sphinx>=1.8.0,<2.0.0;python_version=='2.7' # BSD
+sphinx>=1.8.0,!=2.1.0;python_version>='3.4' # BSD
openstackdocstheme>=1.20.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 0c9143b..27ecde6 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -51,7 +51,7 @@ rfc3986==0.3.1
six==1.10.0
smmap==0.9.0
snowballstemmer==1.2.1
-Sphinx==1.6.2
+Sphinx==1.8.0
sphinxcontrib-websupport==1.0.1
stevedore==1.20.0
stestr==2.0.0
diff --git a/oslo_concurrency/lockutils.py b/oslo_concurrency/lockutils.py
index 7169ee4..7fe049b 100644
--- a/oslo_concurrency/lockutils.py
+++ b/oslo_concurrency/lockutils.py
@@ -281,6 +281,37 @@ def lock(name, lock_file_prefix=None, external=False, lock_path=None,
LOG.debug('Releasing lock "%(lock)s"', {'lock': name})
+def lock_with_prefix(lock_file_prefix):
+ """Partial object generator for the lock context manager.
+
+ Redefine lock in each project like so::
+
+ (in nova/utils.py)
+ from oslo_concurrency import lockutils
+
+ _prefix = 'nova'
+ lock = lockutils.lock_with_prefix(_prefix)
+ lock_cleanup = lockutils.remove_external_lock_file_with_prefix(_prefix)
+
+
+ (in nova/foo.py)
+ from nova import utils
+
+ with utils.lock('mylock'):
+ ...
+
+ Eventually clean up with::
+
+ lock_cleanup('mylock')
+
+ :param lock_file_prefix: A string used to provide lock files on disk with a
+ meaningful prefix. Will be separated from the lock name with a hyphen,
+ which may optionally be included in the lock_file_prefix (e.g.
+ ``'nova'`` and ``'nova-'`` are equivalent).
+ """
+ return functools.partial(lock, lock_file_prefix=lock_file_prefix)
+
+
def synchronized(name, lock_file_prefix=None, external=False, lock_path=None,
semaphores=None, delay=0.01, fair=False):
"""Synchronization decorator.
@@ -350,7 +381,9 @@ def synchronized_with_prefix(lock_file_prefix):
(in nova/utils.py)
from oslo_concurrency import lockutils
- synchronized = lockutils.synchronized_with_prefix('nova-')
+ _prefix = 'nova'
+ synchronized = lockutils.synchronized_with_prefix(_prefix)
+ lock_cleanup = lockutils.remove_external_lock_file_with_prefix(_prefix)
(in nova/foo.py)
@@ -360,8 +393,14 @@ def synchronized_with_prefix(lock_file_prefix):
def bar(self, *args):
...
- The lock_file_prefix argument is used to provide lock files on disk with a
- meaningful prefix.
+ Eventually clean up with::
+
+ lock_cleanup('mylock')
+
+ :param lock_file_prefix: A string used to provide lock files on disk with a
+ meaningful prefix. Will be separated from the lock name with a hyphen,
+ which may optionally be included in the lock_file_prefix (e.g.
+ ``'nova'`` and ``'nova-'`` are equivalent).
"""
return functools.partial(synchronized, lock_file_prefix=lock_file_prefix)
@@ -375,18 +414,25 @@ def remove_external_lock_file_with_prefix(lock_file_prefix):
(in nova/utils.py)
from oslo_concurrency import lockutils
- synchronized = lockutils.synchronized_with_prefix('nova-')
- synchronized_remove = lockutils.remove_external_lock_file_with_prefix(
- 'nova-')
+ _prefix = 'nova'
+ synchronized = lockutils.synchronized_with_prefix(_prefix)
+ lock = lockutils.lock_with_prefix(_prefix)
+ lock_cleanup = lockutils.remove_external_lock_file_with_prefix(_prefix)
(in nova/foo.py)
from nova import utils
@utils.synchronized('mylock')
def bar(self, *args):
- ...
+ ...
+
+ def baz(self, *args):
+ ...
+ with utils.lock('mylock'):
+ ...
+ ...
- <eventually call synchronized_remove('mylock') to cleanup>
+ <eventually call lock_cleanup('mylock') to clean up>
The lock_file_prefix argument is used to provide lock files on disk with a
meaningful prefix.
diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py
index 710b9ae..1bd74a2 100644
--- a/oslo_concurrency/tests/unit/test_lockutils.py
+++ b/oslo_concurrency/tests/unit/test_lockutils.py
@@ -228,6 +228,15 @@ class LockTestCase(test_base.BaseTestCase):
self._do_test_lock_externally()
+ def test_lock_with_prefix(self):
+ # TODO(efried): Embetter this test
+ self.config(lock_path=tempfile.mkdtemp(), group='oslo_concurrency')
+ foo = lockutils.lock_with_prefix('mypfix-')
+
+ with foo('mylock', external=True):
+ # We can't check much
+ pass
+
def test_synchronized_with_prefix(self):
lock_name = 'mylock'
lock_pfix = 'mypfix-'
diff --git a/tox.ini b/tox.ini
index 2a99db9..29547e6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -38,7 +38,7 @@ deps =
-r{toxinidir}/doc/requirements.txt
commands =
rm -fr doc/build
- sphinx-build -W -b html doc/source doc/build/html {posargs}
+ sphinx-build -W --keep-going -b html doc/source doc/build/html {posargs}
[testenv:cover]
basepython = python3
@@ -62,7 +62,8 @@ import_exceptions =
[testenv:releasenotes]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
-commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
+commands =
+ sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
[testenv:lower-constraints]
basepython = python3