def simple_locking(lock_id, expiration=None):
def inner_decorator(function):<EOL><INDENT>def wrapper(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>lock = Lock.acquire_lock(lock_id, expiration)<EOL><DEDENT>except LockError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>logger.debug('<STR_LIT>' % lock_id)<EOL>try:<EOL><INDENT>return function(*args, **kwargs)<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>finally:<EOL><INDENT>lock.release()<EOL><DEDENT><DEDENT><DEDENT>return wraps(function)(wrapper)<EOL><DEDENT>return inner_decorator<EOL>
A decorator that wraps a function in a single lock getting algorithm