summaryrefslogtreecommitdiffstats
path: root/Lib/queue.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-10-31 17:57:52 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-10-31 17:57:52 (GMT)
commit189316a2e35eede0de61c4713777c2b8e04c2e99 (patch)
tree70f0c6ffa126bfd9902d6c7880490bbea7229c78 /Lib/queue.py
parentd285bdb4434a57126f7f17dc6b8f78204c180c1f (diff)
downloadcpython-189316a2e35eede0de61c4713777c2b8e04c2e99.zip
cpython-189316a2e35eede0de61c4713777c2b8e04c2e99.tar.gz
cpython-189316a2e35eede0de61c4713777c2b8e04c2e99.tar.bz2
Issue 10110: Let Queue.put recognize a full queue when the maxsize parameter has been reduced.
Diffstat (limited to 'Lib/queue.py')
-rw-r--r--Lib/queue.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/queue.py b/Lib/queue.py
index f051f1c..bee7ed4 100644
--- a/Lib/queue.py
+++ b/Lib/queue.py
@@ -110,14 +110,14 @@ class Queue:
def full(self):
"""Return True if the queue is full, False otherwise (not reliable!).
- This method is likely to be removed at some point. Use qsize() == n
+ This method is likely to be removed at some point. Use qsize() >= n
as a direct substitute, but be aware that either approach risks a race
condition where a queue can shrink before the result of full() or
qsize() can be used.
"""
self.mutex.acquire()
- n = 0 < self.maxsize == self._qsize()
+ n = 0 < self.maxsize <= self._qsize()
self.mutex.release()
return n
@@ -136,16 +136,16 @@ class Queue:
try:
if self.maxsize > 0:
if not block:
- if self._qsize() == self.maxsize:
+ if self._qsize() >= self.maxsize:
raise Full
elif timeout is None:
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
self.not_full.wait()
elif timeout < 0:
raise ValueError("'timeout' must be a positive number")
else:
endtime = _time() + timeout
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
remaining = endtime - _time()
if remaining <= 0.0:
raise Full