summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-09-12 08:54:20 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-09-12 08:54:54 -0700
commit720997501c815cdb6829c295dbc0e745e90a75c0 (patch)
tree845e32fd044de9006461f5069157d475f43d5416
parent725b14d2fb773c2f4629c54d53a211dd4e6fdab1 (diff)
downloadoslo-incubator-720997501c815cdb6829c295dbc0e745e90a75c0.tar.gz
Always log the releasing, even under failure
Change-Id: I4b87b5d9e5c42a1ab4c837ebb4d45b86faf87c21
-rw-r--r--openstack/common/lockutils.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/openstack/common/lockutils.py b/openstack/common/lockutils.py
index fa5cf898..8dce624d 100644
--- a/openstack/common/lockutils.py
+++ b/openstack/common/lockutils.py
@@ -227,13 +227,15 @@ def lock(name, lock_file_prefix=None, external=False, lock_path=None):
int_lock = internal_lock(name)
with int_lock:
LOG.debug('Acquired semaphore "%(lock)s"', {'lock': name})
- if external and not CONF.disable_process_locking:
- ext_lock = external_lock(name, lock_file_prefix, lock_path)
- with ext_lock:
- yield ext_lock
- else:
- yield int_lock
- LOG.debug('Releasing semaphore "%(lock)s"', {'lock': name})
+ try:
+ if external and not CONF.disable_process_locking:
+ ext_lock = external_lock(name, lock_file_prefix, lock_path)
+ with ext_lock:
+ yield ext_lock
+ else:
+ yield int_lock
+ finally:
+ LOG.debug('Releasing semaphore "%(lock)s"', {'lock': name})
def synchronized(name, lock_file_prefix=None, external=False, lock_path=None):