Workaround issue with greenthreads and lockfiles
* Adds a GreenLockFile that always works in greenthreads * Adds test to verify that regular Lockfile is broken * Adds test to verify that GreenLockfile works * Adds note about limitation of external locks * Adds test showing limitation of nested locks * Fixes bug 956313 Change-Id: I11cd1206611aa4862dadd2fcc077c4c2e0f798f6
This commit is contained in:
@@ -22,6 +22,7 @@ import select
|
||||
|
||||
from eventlet import greenpool
|
||||
from eventlet import greenthread
|
||||
import lockfile
|
||||
|
||||
from nova import exception
|
||||
from nova import test
|
||||
@@ -134,6 +135,21 @@ class LockTestCase(test.TestCase):
|
||||
self.assertEqual(saved_sem_num, len(utils._semaphores),
|
||||
"Semaphore leak detected")
|
||||
|
||||
def test_nested_external_fails(self):
|
||||
"""We can not nest external syncs"""
|
||||
|
||||
@utils.synchronized('testlock1', external=True)
|
||||
def outer_lock():
|
||||
|
||||
@utils.synchronized('testlock2', external=True)
|
||||
def inner_lock():
|
||||
pass
|
||||
inner_lock()
|
||||
try:
|
||||
self.assertRaises(lockfile.NotMyLock, outer_lock)
|
||||
finally:
|
||||
utils.cleanup_file_locks()
|
||||
|
||||
def test_synchronized_externally(self):
|
||||
"""We can lock across multiple processes"""
|
||||
rpipe1, wpipe1 = os.pipe()
|
||||
|
Reference in New Issue
Block a user