@contextmanager<EOL>def lock(vcs, lock_object, wait=True):
if wait:<EOL><INDENT>timeout = -<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>timeout = <NUM_LIT:0><EOL><DEDENT>lock_path = _get_lock_path(vcs, lock_object)<EOL>lock = filelock.FileLock(lock_path)<EOL>with lock.acquire(timeout=timeout):<EOL><INDENT>yield<EOL><DEDENT>
A context manager that grabs the lock and releases it when done.

    This blocks until the lock can be acquired.

    Args:
        vcs (easyci.vcs.base.Vcs)
        lock_object (Lock)
        wait (boolean) - whether to wait for the lock or error out

    Raises:
        Timeout