在 Java 中tryLock(long time, TimeUnit unit)可以用作获取锁的非阻塞尝试。python中的等价物如何实现?(Pythonic |惯用的方式是首选!)
Java tryLock:
ReentrantLock lock1 = new ReentrantLock()
if (lock1.tryLock(13, TimeUnit.SECONDS)) { ... }
蟒蛇锁:
import threading
lock = Lock()
lock.acquire() # how to lock.acquire(timeout = 13) ?