import functools


def with_lock(lock):
    """
    Call function with a lock
    :param lock: lock context manager
    """
    def _(func):
        @functools.wraps(func)
        def f(*args, **kwg):
            with lock:
                return func(*args, **kwg)
        return f
    return _