]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
In asyncio.locks.Lock.acquire(): Avoid deadlock when a cancelled future is in self...
authorGuido van Rossum <guido@python.org>
Tue, 23 Aug 2016 16:39:03 +0000 (09:39 -0700)
committerGuido van Rossum <guido@python.org>
Tue, 23 Aug 2016 16:39:03 +0000 (09:39 -0700)
Lib/asyncio/locks.py

index 741aaf27c5ee65b5e8d775cf3e6a80195e690ccc..deefc938ecfb01d3c0c7438dc6690d42711ffc71 100644 (file)
@@ -166,7 +166,7 @@ class Lock(_ContextManagerMixin):
         This method blocks until the lock is unlocked, then sets it to
         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
             return True