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

This commit is contained in:
Bar Harel 2018-02-14 11:18:11 +02:00 committed by Andrew Svetlov
parent 3384d38d51
commit 5746510b7a
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.