bpo-32841: Fix cancellation in awaiting asyncio.Condition (GH-5665)

(cherry picked from commit 5746510b7a)

Co-authored-by: Bar Harel <bzvi7919@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-02-14 01:47:30 -08:00 committed by GitHub
parent 8e29fd4b3b
commit 8caee0fa57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 5 deletions

View file

@ -358,12 +358,16 @@ class Condition(_ContextManagerMixin):
finally:
# Must reacquire lock even if wait is cancelled
cancelled = False
while True:
try:
await self.acquire()
break
except futures.CancelledError:
pass
cancelled = True
if cancelled:
raise futures.CancelledError
async def wait_for(self, predicate):
"""Wait until a predicate becomes true.