PyDocs

Nav

Concurrent Execution

BoundedSemaphore

threading

class (source) not WASI
  • BoundedSemaphore(value=1)
Implements a bounded semaphore.

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.

Like regular semaphores, bounded semaphores manage a counter representing
the number of release() calls minus the number of acquire() calls, plus an
initial value. The acquire() method blocks if necessary until it can return
without making the counter negative. If not given, value defaults to 1.
Changed in 3.3
  • 3.3: changed from a factory function to a class.
0 Examples
No examples for threading/BoundedSemaphore.
See Also
No see-alsos for threading/BoundedSemaphore
0 Notes
No notes for BoundedSemaphore