How to implement a Lock with a timeout in Python 2.7
to elaborate on Steven’s comment suggestion: import threading import time 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 Things to notice: there are two threading.Lock() objects, one … Read more