Hum, I didn't get any reply to this message :-( I opened an issue to
at least document the behaviour:
https://bugs.python.org/issue23859
By the way, while discussing with Natim on IRC, we found a bug in the
websockets project which uses wait() on a queue.get() task. If the
wait() is cancelled, you can loose an item of the queue if the get
task is not called. See my fix:
diff --git a/websockets/protocol.py b/websockets/protocol.py
index 7e4a94e..5353b74 100644
--- a/websockets/protocol.py
+++ b/websockets/protocol.py
@@ -166,9 +166,13 @@ class
WebSocketCommonProtocol(asyncio.StreamReaderProtocol):
# Wait for a message until the connection is closed
next_message = asyncio.async(self.messages.get(), loop=self._loop)
- done, pending = yield from asyncio.wait(
- [next_message, self.worker],
- loop=self._loop, return_when=asyncio.FIRST_COMPLETED)
+ try:
+ done, pending = yield from asyncio.wait(
+ [next_message, self.worker],
+ loop=self._loop, return_when=asyncio.FIRST_COMPLETED)
+ except:
+ next_message.cancel()
+ raise
if next_message in done:
return next_message.result()
else:
The full recv() method:
https://github.com/aaugustin/websockets/blob/7d8191699a6d647c1b45e3e11681c5987437e5b5/websockets/protocol.py#L149
Victor