Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait.
Patch by David Coles.
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index 842d621..741aaf2 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -329,7 +329,13 @@
self._waiters.remove(fut)
finally:
- yield from self.acquire()
+ # Must reacquire lock even if wait is cancelled
+ while True:
+ try:
+ yield from self.acquire()
+ break
+ except futures.CancelledError:
+ pass
@coroutine
def wait_for(self, predicate):