Merge "Always log the releasing, even under failure"

This commit is contained in:
Jenkins 2014-09-19 02:31:30 +00:00 committed by Gerrit Code Review
commit 9d61eed7c1
1 changed files with 9 additions and 7 deletions

View File

@ -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):