summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorTim Peters <tim@python.org>2013-10-09 02:12:58 (GMT)
committerTim Peters <tim@python.org>2013-10-09 02:12:58 (GMT)
commite99bdb9694dd472fda932926d87cd6d783ec5da8 (patch)
treeae646be60a30d6a478235350fc1dc1262e3ab9f8 /Lib/threading.py
parent77e904e6a6d8fefd8c6100ea33cf46fb69b45efd (diff)
parent7634e1cf9028ed5b21f0a97db45c91d8e8a159a6 (diff)
downloadcpython-e99bdb9694dd472fda932926d87cd6d783ec5da8.zip
cpython-e99bdb9694dd472fda932926d87cd6d783ec5da8.tar.gz
cpython-e99bdb9694dd472fda932926d87cd6d783ec5da8.tar.bz2
Issue 19158: a rare race in BoundedSemaphore could allow .release() too often.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 26d1018..b99d0e9 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -289,9 +289,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: