From c92bf83a829956e683a3d6bb1ae65aed74d7b92a Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sat, 11 Jun 2016 12:00:07 -0400 Subject: Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait. Patch by David Coles. --- Lib/asyncio/locks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Lib/asyncio/locks.py') diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py index 842d6210d5..741aaf27c5 100644 --- a/Lib/asyncio/locks.py +++ b/Lib/asyncio/locks.py @@ -329,7 +329,13 @@ class Condition(_ContextManagerMixin): 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): -- cgit v1.2.1