本文整理汇总了Python中pycassa.ConnectionPool._replace_wrapper方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectionPool._replace_wrapper方法的具体用法?Python ConnectionPool._replace_wrapper怎么用?Python ConnectionPool._replace_wrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycassa.ConnectionPool
的用法示例。
在下文中一共展示了ConnectionPool._replace_wrapper方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_queue_failure_on_retry
# 需要导入模块: from pycassa import ConnectionPool [as 别名]
# 或者: from pycassa.ConnectionPool import _replace_wrapper [as 别名]
def test_queue_failure_on_retry(self):
listener = _TestListener()
pool = ConnectionPool(pool_size=5, max_overflow=5, recycle=10000,
prefill=True, max_retries=3, # allow 3 retries
keyspace='PycassaTestKeyspace', credentials=_credentials,
listeners=[listener], use_threadlocal=False,
server_list=['localhost:9160', 'localhost:9160'])
def raiser():
raise IOError
# Replace wrapper will open a connection to get the version, so if it
# fails we need to retry as with any other connection failure
pool._replace_wrapper = raiser
# Corrupt all of the connections
for i in range(5):
conn = pool.get()
setattr(conn, 'send_batch_mutate', conn._fail_once)
conn._should_fail = True
conn.return_to_pool()
cf = ColumnFamily(pool, 'Standard1')
assert_raises(MaximumRetryException, cf.insert, 'key', {'col':'val', 'col2': 'val'})
assert_equal(listener.failure_count, 4) # On the 4th failure, didn't retry
pool.dispose()