Commit d4803c24 authored by Guido Trotter's avatar Guido Trotter
Browse files

Fix LockSet._names() to work with the set-lock

If the set-lock is acquired, currently, the _names function will fail on
a double acquire of a non-recursive lock. This patch fixes the behavior,
and some lines of code added to the testAcquireSetLock test check that
this and other functioins behave properly.

Reviewed-by: imsnah
parent aefef4f4
......@@ -390,10 +390,16 @@ class LockSet:
Used only for debugging purposes.
# If we don't already own the set-level lock acquired
# we'll get it and note we need to release it later.
release_lock = False
if not self.__lock._is_owned():
release_lock = True
result = self.__names()
if release_lock:
return set(result)
......@@ -393,6 +393,9 @@ class TestLockSet(unittest.TestCase):
def testAcquireSetLock(self):
# acquire the set-lock exclusively
self.assertEquals(, set(['one', 'two', 'three']))
self.assertEquals(, set(['one', 'two', 'three']))
self.assertEquals(, True)
self.assertEquals(, set(['one', 'two', 'three']))
# I can still add/remove elements...
self.assertEquals(['two', 'three']), ['two', 'three'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment