This commit is contained in:
Kovid Goyal 2011-07-10 15:12:06 -06:00
parent da38d6cca9
commit 62e418f3f7

View File

@ -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)
time.sleep(0.2) with r:
lock.acquire(blocking=True, shared=True) time.sleep(0.2)
lock.release() with r:
lock.release() pass
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