lock = threading.Lock()
cond = threading.Condition(threading.Lock())

def waitLock(timeout):
    with cond:
        current_time = start_time = time.time()
while current_time < start_time + timeout:
    if lock.acquire(False):
        return True
else:
    cond.wait(timeout - current_time + start_time)
current_time = time.time()
return False
How to implement a Lock with a timeout in Python 2.7