From 671fe4303994cee5078bfc2716993d20922f295a Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 14 Sep 2014 20:10:32 -0400 Subject: [PATCH] Always log the releasing, even under failure Cherry picked from oslo-incubator change id: I4b87b5d9e5c42a1ab4c837ebb4d45b86faf87c21 Change-Id: Iae1b9035398e283b5837a3214cf0097022af54a9 Related-Bug: #1367941 --- nova/openstack/common/lockutils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/nova/openstack/common/lockutils.py b/nova/openstack/common/lockutils.py index 29827dd532f3..cea31544ec37 100644 --- a/nova/openstack/common/lockutils.py +++ b/nova/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):