In Java tryLock(long time, TimeUnit unit) can be used as a non-blocking attempt to acquire the lock. How can the equivalent in python be achieved? (Pythonic | idiomatic way is preferred!)
Java tryLock:
ReentrantLock lock1 = new ReentrantLock() if (lock1.tryLock(13, TimeUnit.SECONDS)) { ... } Python Lock:
import threading lock = Lock() lock.acquire() # how to lock.acquire(timeout = 13) ?