From 9a39f854c77adfa04a463c13e2743dd88d3c7509 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Tue, 4 Mar 2008 17:11:47 +0000
Subject: [PATCH] SharedLock: remove wrong assertion in code

r644 contained some cleanup code for LockSet. Among other things it removed a
syntax error that allowed an assertion that previously wan't really checked to
trigger. It turns out that even though the spirit of that assertion was correct
its actual implementation was wrong.

While it's true that no sharers must be waiting if an exclusive holder is not
present it might happen that when all the sharers wake up one of them releases
the lock before some other even has had a chance to run. In this case
__shr_wait would still be greater than 0, even if the sharer is not actually
waiting, just pending a wakeup to proceed.

Thus, removing the assertion in question.

Reviewed-by: imsnah
---
 lib/locking.py | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/lib/locking.py b/lib/locking.py
index 09d2afa83..a90c96f02 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -207,11 +207,6 @@ class SharedLock:
       elif self.__is_sharer():
         self.__shr.remove(threading.currentThread())
 
-        # If there are shared holders waiting there *must* be an exclusive holder
-        # waiting as well; otherwise what were they waiting for?
-        assert self.__nwait_shr == 0 or self.__nwait_exc > 0, \
-               "Lock sharers waiting while no exclusive is queueing"
-
         # If there are no more shared holders and some exclusive holders are
         # waiting let's wake one up.
         if len(self.__shr) == 0 and self.__nwait_exc > 0:
-- 
GitLab