summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2015-04-20 16:29:57 (GMT)
committerGuido van Rossum <guido@python.org>2015-04-20 16:29:57 (GMT)
commitf75d4a7ad00af30dea81e478915696c7106ff3ec (patch)
treee645ca672c776d45c1d7bbcdfa5687db815b03aa /Lib/asyncio
parent629d697f969cef4e5b5ec986700ac10908a0d075 (diff)
parent0bd16bc4cdbb896e6f201f14e43fd44580024362 (diff)
downloadcpython-f75d4a7ad00af30dea81e478915696c7106ff3ec.zip
cpython-f75d4a7ad00af30dea81e478915696c7106ff3ec.tar.gz
cpython-f75d4a7ad00af30dea81e478915696c7106ff3ec.tar.bz2
Fix asyncio issue 235 (merge from 3.4).
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/queues.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index 264e1ce..50543c8 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -53,6 +53,8 @@ class Queue:
self._finished.set()
self._init(maxsize)
+ # These three are overridable in subclasses.
+
def _init(self, maxsize):
self._queue = collections.deque()
@@ -61,6 +63,11 @@ class Queue:
def _put(self, item):
self._queue.append(item)
+
+ # End of the overridable methods.
+
+ def __put_internal(self, item):
+ self._put(item)
self._unfinished_tasks += 1
self._finished.clear()
@@ -132,7 +139,7 @@ class Queue:
'queue non-empty, why are getters waiting?')
getter = self._getters.popleft()
- self._put(item)
+ self.__put_internal(item)
# getter cannot be cancelled, we just removed done getters
getter.set_result(self._get())
@@ -144,7 +151,7 @@ class Queue:
yield from waiter
else:
- self._put(item)
+ self.__put_internal(item)
def put_nowait(self, item):
"""Put an item into the queue without blocking.
@@ -157,7 +164,7 @@ class Queue:
'queue non-empty, why are getters waiting?')
getter = self._getters.popleft()
- self._put(item)
+ self.__put_internal(item)
# getter cannot be cancelled, we just removed done getters
getter.set_result(self._get())
@@ -165,7 +172,7 @@ class Queue:
elif self._maxsize > 0 and self._maxsize <= self.qsize():
raise QueueFull
else:
- self._put(item)
+ self.__put_internal(item)
@coroutine
def get(self):
@@ -179,7 +186,7 @@ class Queue:
if self._putters:
assert self.full(), 'queue not full, why are putters waiting?'
item, putter = self._putters.popleft()
- self._put(item)
+ self.__put_internal(item)
# When a getter runs and frees up a slot so this putter can
# run, we need to defer the put for a tick to ensure that
@@ -206,7 +213,7 @@ class Queue:
if self._putters:
assert self.full(), 'queue not full, why are putters waiting?'
item, putter = self._putters.popleft()
- self._put(item)
+ self.__put_internal(item)
# Wake putter on next tick.
# getter cannot be cancelled, we just removed done putters