In asyncio.locks.Lock.acquire(): Avoid deadlock when a cancelled future is in self._waiters.

This commit is contained in:
Guido van Rossum 2016-08-23 09:39:03 -07:00
parent 4b7b565c58
commit 83f5a3846c

View file

@ -166,7 +166,7 @@ class Lock(_ContextManagerMixin):
This method blocks until the lock is unlocked, then sets it to This method blocks until the lock is unlocked, then sets it to
locked and returns True. locked and returns True.
""" """
if not self._waiters and not self._locked: if not self._locked and all(w.cancelled() for w in self._waiters):
self._locked = True self._locked = True
return True return True