diff options
author | Zuul <zuul@review.opendev.org> | 2019-11-29 16:25:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-11-29 16:25:39 +0000 |
commit | 2ab42ddec4fe1124fce4bedfb4ce1fdd7e329778 (patch) | |
tree | 173ce604b33b55dd023c5b5cf3a642fa220dc769 | |
parent | 34c0ed87b68520e2094b5498b18974e5ea28bbc2 (diff) | |
parent | c08159119e605dea76580032ca85834d1de21d3e (diff) | |
download | oslo-concurrency-2ab42ddec4fe1124fce4bedfb4ce1fdd7e329778.tar.gz |
Merge "Spiff up docs for *_with_prefix"3.31.0
-rw-r--r-- | oslo_concurrency/lockutils.py | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/oslo_concurrency/lockutils.py b/oslo_concurrency/lockutils.py index ba0d0a5..7fe049b 100644 --- a/oslo_concurrency/lockutils.py +++ b/oslo_concurrency/lockutils.py @@ -289,7 +289,9 @@ def lock_with_prefix(lock_file_prefix): (in nova/utils.py) from oslo_concurrency import lockutils - lock = lockutils.lock_with_prefix('nova-') + _prefix = 'nova' + lock = lockutils.lock_with_prefix(_prefix) + lock_cleanup = lockutils.remove_external_lock_file_with_prefix(_prefix) (in nova/foo.py) @@ -298,8 +300,14 @@ def lock_with_prefix(lock_file_prefix): with utils.lock('mylock'): ... - 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(lock, lock_file_prefix=lock_file_prefix) @@ -373,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) @@ -383,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) @@ -398,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. |