<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lock(vcs, lock_object, wait=True):
 """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 """

    if wait:
        timeout = -1
    else:
        timeout = 0
    lock_path = _get_lock_path(vcs, lock_object)
    lock = filelock.FileLock(lock_path)
    with lock.acquire(timeout=timeout):
        yield