bpo-10978: Semaphores can release multiple threads at a time (GH-15588)

This commit is contained in:
Raymond Hettinger 2019-08-29 01:45:19 -07:00 committed by GitHub
parent 0dac68f1e5
commit 35f6301d68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 13 deletions

View file

@ -802,11 +802,14 @@ Semaphores also support the :ref:`context management protocol <with-locks>`.
.. versionchanged:: 3.2
The *timeout* parameter is new.
.. method:: release()
.. method:: release(n=1)
Release a semaphore, incrementing the internal counter by one. When it
was zero on entry and another thread is waiting for it to become larger
than zero again, wake up that thread.
Release a semaphore, incrementing the internal counter by *n*. When it
was zero on entry and other threads are waiting for it to become larger
than zero again, wake up *n* of those threads.
.. versionchanged:: 3.9
Added the *n* parameter to release multiple waiting threads at once.
.. class:: BoundedSemaphore(value=1)