def test_select_for_update_locks_released(self): lock_impl = lock.SelectForUpdateLock(attempts=4) thread1 = threading.Thread(target=self.run_with_lock_and_release, args=[lock_impl]) thread2 = threading.Thread(target=self.run_with_lock_and_release, args=[lock_impl]) thread1.start() thread2.start() thread1.join() thread2.join() try: self.exception_queue.get(True, 1) self.fail('Thread was blocked') except queue.Empty: pass
def test_select_for_update_locks(self): lock_impl = lock.SelectForUpdateLock(attempts=1) thread1 = threading.Thread(target=self.run_with_lock, args=[lock_impl]) thread2 = threading.Thread(target=self.run_with_lock, args=[lock_impl]) thread1.start() thread2.start() try: self.exception_queue.get(True, 10) except queue.Empty: self.fail('No thread was blocked') finally: self.finished = True thread1.join() thread2.join()
def test_func(): lock_impl = lock.SelectForUpdateLock(attempts=4) with lock_impl(Test.TestFlow)(Test.TestFlow, self.process.pk): raise DatabaseError('Test')