From 62e418f3f7b58daa03a1ef24f0be274a05e65a63 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Jul 2011 15:12:06 -0600 Subject: [PATCH] ... --- src/calibre/db/locking.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/calibre/db/locking.py b/src/calibre/db/locking.py index 0b34855d01..bf98c5f4f1 100644 --- a/src/calibre/db/locking.py +++ b/src/calibre/db/locking.py @@ -214,14 +214,16 @@ if __name__ == '__main__': 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