本文整理汇总了Python中cassandra.cluster.ResponseFuture._retry_task方法的典型用法代码示例。如果您正苦于以下问题:Python ResponseFuture._retry_task方法的具体用法?Python ResponseFuture._retry_task怎么用?Python ResponseFuture._retry_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cassandra.cluster.ResponseFuture
的用法示例。
在下文中一共展示了ResponseFuture._retry_task方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_retry_policy_says_retry
# 需要导入模块: from cassandra.cluster import ResponseFuture [as 别名]
# 或者: from cassandra.cluster.ResponseFuture import _retry_task [as 别名]
def test_retry_policy_says_retry(self):
session = self.make_session()
pool = session._pools.get.return_value
query = SimpleStatement("INSERT INFO foo (a, b) VALUES (1, 2)")
query.retry_policy = Mock()
query.retry_policy.on_unavailable.return_value = (RetryPolicy.RETRY, ConsistencyLevel.ONE)
message = QueryMessage(query=query, consistency_level=ConsistencyLevel.QUORUM)
rf = ResponseFuture(session, message, query)
rf.send_request()
rf.session._pools.get.assert_called_once_with('ip1')
pool.borrow_connection.assert_called_once_with(timeout=ANY)
connection = pool.borrow_connection.return_value
connection.send_msg.assert_called_once_with(rf.message, cb=ANY)
result = Mock(spec=UnavailableErrorMessage, info={})
rf._set_result(result)
session.submit.assert_called_once_with(rf._retry_task, True)
self.assertEqual(1, rf._query_retries)
# simulate the executor running this
rf._retry_task(True)
# it should try again with the same host since this was
# an UnavailableException
rf.session._pools.get.assert_called_with('ip1')
pool.borrow_connection.assert_called_with(timeout=ANY)
connection = pool.borrow_connection.return_value
connection.send_msg.assert_called_with(rf.message, cb=ANY)