pathex.adts.concurrency.counted_condition module
- class CountedCondition(lock)[source]
Bases:
threading.Condition
- Parameters
lock_class (Lock) – This is the class of the underlying lock.
- notify(n: int = 1) None [source]
Wake up one or more threads 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.
- wait() bool [source]
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 be a floating point number specifying a timeout for the operation in seconds (or fractions thereof).
When the underlying lock is an RLock, it is not released using its release() method, since this may not actually unlock the lock when it was acquired multiple times recursively. Instead, an internal interface of the RLock class is used, which really unlocks it even when it has been recursively acquired several times. Another internal interface is then used to restore the recursion level when the lock is reacquired.