mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 15:23:39 +02:00
...
This commit is contained in:
parent
da38d6cca9
commit
62e418f3f7
1 changed files with 8 additions and 6 deletions
|
|
@ -214,14 +214,16 @@ class TestSHLock(unittest.TestCase):
|
|||
def test_multithread_deadlock(self):
|
||||
lock = SHLock()
|
||||
def two_shared():
|
||||
lock.acquire(shared=True)
|
||||
time.sleep(0.2)
|
||||
lock.acquire(blocking=True, shared=True)
|
||||
lock.release()
|
||||
lock.release()
|
||||
r = RWLockWrapper(lock)
|
||||
with r:
|
||||
time.sleep(0.2)
|
||||
with r:
|
||||
pass
|
||||
def one_exclusive():
|
||||
time.sleep(0.1)
|
||||
lock.acquire(blocking=True, shared=False)
|
||||
w = RWLockWrapper(lock, is_shared=False)
|
||||
with w:
|
||||
pass
|
||||
threads = [Thread(target=two_shared), Thread(target=one_exclusive)]
|
||||
for t in threads:
|
||||
t.daemon = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue