def test_select_for_update_locks(self): thread1 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(attempts=1)]) thread2 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(attempts=1)]) 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_select_for_update_locks(self): thread1 = threading.Thread(target=self.run_with_lock, args=[lock.select_for_update_lock(Test.TestFlow, attempts=1)]) thread2 = threading.Thread(target=self.run_with_lock, args=[lock.select_for_update_lock(Test.TestFlow, attempts=1)]) 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_select_for_update_locks_released(self): thread1 = threading.Thread( target=self.run_with_lock_and_release, args=[lock.select_for_update_lock(Test.TestFlow, attempts=4)]) thread2 = threading.Thread( target=self.run_with_lock_and_release, args=[lock.select_for_update_lock(Test.TestFlow, attempts=4)]) 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 = select_for_update_lock(NoTaskFlow, attempts=1) with lock(NoTaskFlow.end, self.process.pk): pass thread1 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(NoTaskFlow, attempts=1)]) thread2 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(NoTaskFlow, attempts=1)]) 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_select_for_update_locks(self): lock = select_for_update_lock(NoTaskFlow, attempts=1) with lock(NoTaskFlow, self.process.pk): pass thread1 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(NoTaskFlow, attempts=1)]) thread2 = threading.Thread(target=self.run_with_lock, args=[select_for_update_lock(NoTaskFlow, attempts=1)]) 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()