@@ -684,8 +684,8 @@ Semaphores also support the :ref:`context management protocol <with-locks>`.
684
684
685
685
.. class :: Semaphore(value=1)
686
686
687
- This class implements semaphore objects. A semaphore manages a counter
688
- representing the number of :meth: `release ` calls minus the number of
687
+ This class implements semaphore objects. A semaphore manages an atomic
688
+ counter representing the number of :meth: `release ` calls minus the number of
689
689
:meth: `acquire ` calls, plus an initial value. The :meth: `acquire ` method
690
690
blocks if necessary until it can return without making the counter negative.
691
691
If not given, *value * defaults to 1.
@@ -701,19 +701,19 @@ Semaphores also support the :ref:`context management protocol <with-locks>`.
701
701
702
702
Acquire a semaphore.
703
703
704
- When invoked without arguments: if the internal counter is larger than
705
- zero on entry, decrement it by one and return immediately. If it is zero
706
- on entry, block, waiting until some other thread has called
707
- :meth: ` ~Semaphore.release ` to make it larger than zero. This is done
708
- with proper interlocking so that if multiple :meth: ` acquire ` calls are
709
- blocked, :meth: `~Semaphore.release ` will wake exactly one of them up.
710
- The implementation may pick one at random, so the order in which
711
- blocked threads are awakened should not be relied on. Returns
712
- true (or blocks indefinitely) .
704
+ When invoked without arguments:
705
+
706
+ * If the internal counter is larger than zero on entry, decrement it by
707
+ one and return true immediately.
708
+ * If the internal counter is zero on entry, block until awoken by a call to
709
+ :meth: `~Semaphore.release `. Once awoken (and the counter is greater
710
+ than 0), decrement the counter by 1 and return true. Exactly one
711
+ thread will be awoken by each call to :meth: ` ~Semaphore.release `. The
712
+ order in which threads are awoken should not be relied on .
713
713
714
714
When invoked with *blocking * set to false, do not block. If a call
715
- without an argument would block, return false immediately; otherwise,
716
- do the same thing as when called without arguments, and return true.
715
+ without an argument would block, return false immediately; otherwise, do
716
+ the same thing as when called without arguments, and return true.
717
717
718
718
When invoked with a *timeout * other than ``None ``, it will block for at
719
719
most *timeout * seconds. If acquire does not complete successfully in
0 commit comments