Always log the releasing, even under failure

Change-Id: Ic040d2cad5004caa8786793373fbd5baca54d32e
This commit is contained in:
Joshua Harlow
2014-09-12 09:03:29 -07:00
parent 19e0feb5a1
commit a14a75f0a1

View File

@@ -234,13 +234,15 @@ def lock(name, lock_file_prefix=None, external=False, lock_path=None):
int_lock = internal_lock(name) int_lock = internal_lock(name)
with int_lock: with int_lock:
LOG.debug('Acquired semaphore "%(lock)s"', {'lock': name}) LOG.debug('Acquired semaphore "%(lock)s"', {'lock': name})
if external and not CONF.disable_process_locking: try:
ext_lock = external_lock(name, lock_file_prefix, lock_path) if external and not CONF.disable_process_locking:
with ext_lock: ext_lock = external_lock(name, lock_file_prefix, lock_path)
yield ext_lock with ext_lock:
else: yield ext_lock
yield int_lock else:
LOG.debug('Releasing semaphore "%(lock)s"', {'lock': name}) yield int_lock
finally:
LOG.debug('Releasing semaphore "%(lock)s"', {'lock': name})
def synchronized(name, lock_file_prefix=None, external=False, lock_path=None): def synchronized(name, lock_file_prefix=None, external=False, lock_path=None):