From a14a75f0a19c2c49075589800560b6c74d2553e7 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 12 Sep 2014 09:03:29 -0700 Subject: [PATCH] Always log the releasing, even under failure Change-Id: Ic040d2cad5004caa8786793373fbd5baca54d32e --- oslo/concurrency/lockutils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/oslo/concurrency/lockutils.py b/oslo/concurrency/lockutils.py index e77b097..5ac28a7 100644 --- a/oslo/concurrency/lockutils.py +++ b/oslo/concurrency/lockutils.py @@ -234,13 +234,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):