Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83f5a38

Browse files
committed
In asyncio.locks.Lock.acquire(): Avoid deadlock when a cancelled future is in self._waiters.
1 parent 4b7b565 commit 83f5a38

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Lib/asyncio/locks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def acquire(self):
166166
This method blocks until the lock is unlocked, then sets it to
167167
locked and returns True.
168168
"""
169-
if not self._waiters and not self._locked:
169+
if not self._locked and all(w.cancelled() for w in self._waiters):
170170
self._locked = True
171171
return True
172172

0 commit comments

Comments
 (0)