threading.Condition.wait_for()

wait_for(predicate, timeout=None) Wait until a condition evaluates to True. predicate should be a callable which result will be interpreted as a boolean value. A timeout may be provided giving the maximum time to wait. This utility method may call wait() repeatedly until the predicate is satisfied, or until a timeout occurs. The return value is the last return value of the predicate and will evaluate to False if the method timed out. Ignoring the timeout feature, calling this method is rough

threading.Condition.wait()

wait(timeout=None) Wait until notified or until a timeout occurs. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another thread, or until the optional timeout occurs. Once awakened or timed out, it re-acquires the lock and returns. When the timeout argument is present and not None, it should

threading.Condition.release()

release() Release the underlying lock. This method calls the corresponding method on the underlying lock; there is no return value.

threading.Condition.notify_all()

notify_all() Wake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised.

threading.Condition.notify()

notify(n=1) By default, wake up one thread waiting on this condition, if any. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the threads waiting for the condition variable; it is a no-op if no threads are waiting. The current implementation wakes up exactly n threads, if at least n threads are waiting. However, it’s not safe to rely on this behavior. A future, optimized implementation may occasionally wa

threading.Condition.acquire()

acquire(*args) Acquire the underlying lock. This method calls the corresponding method on the underlying lock; the return value is whatever that method returns.

threading.Condition

class threading.Condition(lock=None) This class implements condition variable objects. A condition variable allows one or more threads to wait until they are notified by another thread. If the lock argument is given and not None, it must be a Lock or RLock object, and it is used as the underlying lock. Otherwise, a new RLock object is created and used as the underlying lock. Changed in version 3.3: changed from a factory function to a class. acquire(*args) Acquire the underlying lock. T

threading.BrokenBarrierError

exception threading.BrokenBarrierError This exception, a subclass of RuntimeError, is raised when the Barrier object is reset or broken.

threading.BoundedSemaphore

class threading.BoundedSemaphore(value=1) Class implementing bounded semaphore objects. A bounded semaphore checks to make sure its current value doesn’t exceed its initial value. If it does, ValueError is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is released too many times it’s a sign of a bug. If not given, value defaults to 1. Changed in version 3.3: changed from a factory function to a class.

threading.Barrier.wait()

wait(timeout=None) Pass the barrier. When all the threads party to the barrier have called this function, they are all released simultaneously. If a timeout is provided, it is used in preference to any that was supplied to the class constructor. The return value is an integer in the range 0 to parties – 1, different for each thread. This can be used to select a thread to do some special housekeeping, e.g.: i = barrier.wait() if i == 0: # Only one thread needs to print this print("pas