import functools


def synchronize(lock):
    """ Decorator that invokes the lock acquire call before a function call and releases after """
    def sync_func(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            lock.acquire()
            res = func(*args, **kwargs)
            lock.release()
            return res
        return wrapper
    return sync_func