[entropy.locks] set recursed to False only when the reference counter is 0
This commit is contained in:
@@ -187,9 +187,6 @@ class _GenericResourceLock(object):
|
||||
lock_path = self.path()
|
||||
with self._lock_mutex:
|
||||
|
||||
# allow the same thread to acquire the lock again.
|
||||
self._TLS.recursed = False
|
||||
|
||||
mapped = self._file_lock_setup(lock_path)
|
||||
|
||||
if mapped['count'] == 0:
|
||||
@@ -210,6 +207,9 @@ class _GenericResourceLock(object):
|
||||
ref_obj.close()
|
||||
mapped['ref'] = None
|
||||
|
||||
# allow the same thread to acquire the lock again.
|
||||
self._TLS.recursed = False
|
||||
|
||||
def _file_lock_create(self, lock_path, blocking=False, shared=False):
|
||||
"""
|
||||
Create and allocate the lock file pointed by lock_data structure.
|
||||
|
||||
@@ -97,7 +97,7 @@ class EntropyLocksTest(unittest.TestCase):
|
||||
|
||||
erl.release()
|
||||
|
||||
self.assertEquals(False, erl.try_acquire_exclusive())
|
||||
self.assertRaises(RuntimeError, erl.try_acquire_exclusive)
|
||||
|
||||
erl.release()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user