Skip to content
Snippets Groups Projects
Commit 9a39f854 authored by Guido Trotter's avatar Guido Trotter
Browse files

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
parent cdb08f44
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment