mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue 19158: a rare race in BoundedSemaphore could allow .release() too often.
This commit is contained in:
parent
ee82d0b293
commit
7634e1cf90
2 changed files with 23 additions and 3 deletions
|
@ -283,9 +283,11 @@ class BoundedSemaphore(Semaphore):
|
|||
self._initial_value = value
|
||||
|
||||
def release(self):
|
||||
if self._value >= self._initial_value:
|
||||
raise ValueError("Semaphore released too many times")
|
||||
return Semaphore.release(self)
|
||||
with self._cond:
|
||||
if self._value >= self._initial_value:
|
||||
raise ValueError("Semaphore released too many times")
|
||||
self._value += 1
|
||||
self._cond.notify()
|
||||
|
||||
|
||||
class Event:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue