def test_try_lock_on_wait_key_cancelled_error(self):
     # Wait key cancelled error comes from the server, invalid fence is returned
     self.prepare_acquire_session(1)
     self.mock_request_try_lock(2, WaitKeyCancelledError())
     self.assertEqual(FencedLock.INVALID_FENCE, self.proxy.try_lock())
     self.assert_call_counts(1, 1, 0)
     self.assert_no_lock_session_id()
    def test_try_acquire_on_wait_key_cancelled_error(self):
        # Server sends wait key cancelled error, should not retry
        self.prepare_thread_id(23)
        self.mock_acquire_request(False, WaitKeyCancelledError())

        with self.assertRaises(IllegalStateError):
            self.semaphore.try_acquire()
 def test_try_acquire_on_wait_key_cancelled_error(self):
     # Wait key cancelled error comes from the server, should not retry
     self.prepare_acquire_session(12)
     self.mock_request_acquire(True, WaitKeyCancelledError())
     self.assertFalse(self.semaphore.try_acquire())
     self.assert_call_counts(1, 1, 0)
     self.assert_acquire_count(1)
     self.assert_release_count(12, 1)
    def test_lock_on_wait_key_cancelled_error(self):
        # Wait key cancelled error comes from the server, should not retry
        self.prepare_acquire_session(1)
        self.mock_request_lock(2, WaitKeyCancelledError())

        with self.assertRaises(IllegalMonitorStateError):
            self.proxy.lock()

        self.assert_call_counts(1, 1, 0)
        self.assert_no_lock_session_id()