summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/queues.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index 512ea60..2a8d3e7 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -121,6 +121,13 @@ class Queue:
await putter
except:
putter.cancel() # Just in case putter is not done yet.
+ try:
+ # Clean self._putters from canceled putters.
+ self._putters.remove(putter)
+ except ValueError:
+ # The putter could be removed from self._putters by a
+ # previous get_nowait call.
+ pass
if not self.full() and not putter.cancelled():
# We were woken up by get_nowait(), but can't take
# the call. Wake up the next in line.
@@ -152,12 +159,13 @@ class Queue:
await getter
except:
getter.cancel() # Just in case getter is not done yet.
-
try:
+ # Clean self._getters from canceled getters.
self._getters.remove(getter)
except ValueError:
+ # The getter could be removed from self._getters by a
+ # previous put_nowait call.
pass
-
if not self.empty() and not getter.cancelled():
# We were woken up by put_nowait(), but can't take
# the call. Wake up the next in line.