[issue8800] add threading.RWLock
Richard Oudkerk
report at bugs.python.org
Mon Oct 1 14:16:35 CEST 2012
Richard Oudkerk added the comment:
I think Sebastian's algorithm does not correctly deal with the non-blocking case. Consider the following situation:
* Thread-1 successfully acquires exclusive lock.
Now num_got_lock == 1.
* Thread-2 blocks waiting for shared lock.
Will block until (num_got_lock == 1 and excl_count == 0).
Now num_got_lock == 1.
* Thread-3 does non-blocking acquire of shared lock but fails.
Now num_got_lock == 2.
Now, since num_got_lock == 2, the predicate that Thread-2 is waiting for will not happen until num_got_lock overflows.
This is probably fixable if we just prevent a failed non-blocking acquire from modifying num_acq_lock and num_got_lock. (But I don't see how to extend the algorithm to allow timeouts.)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8800>
_______________________________________
More information about the Python-bugs-list
mailing list