mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
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:
parent
8e29fd4b3b
commit
8caee0fa57
3 changed files with 34 additions and 5 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue