mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
...
This commit is contained in:
parent
da38d6cca9
commit
62e418f3f7
@ -214,14 +214,16 @@ if __name__ == '__main__':
|
|||||||
def test_multithread_deadlock(self):
|
def test_multithread_deadlock(self):
|
||||||
lock = SHLock()
|
lock = SHLock()
|
||||||
def two_shared():
|
def two_shared():
|
||||||
lock.acquire(shared=True)
|
r = RWLockWrapper(lock)
|
||||||
|
with r:
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
lock.acquire(blocking=True, shared=True)
|
with r:
|
||||||
lock.release()
|
pass
|
||||||
lock.release()
|
|
||||||
def one_exclusive():
|
def one_exclusive():
|
||||||
time.sleep(0.1)
|
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)]
|
threads = [Thread(target=two_shared), Thread(target=one_exclusive)]
|
||||||
for t in threads:
|
for t in threads:
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user