Skip to content

Commit

Permalink
Merge remote-tracking branch 'formspring/callback_info' into callback…
Browse files Browse the repository at this point in the history
…_info_merge

Conflicts:
	tests/test_connection_pooling.py
  • Loading branch information
thobbs committed Mar 28, 2012
2 parents 658ab4d + 6153eb0 commit 2d4c31e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions pycassa/pool.py
Expand Up @@ -109,6 +109,7 @@ def _replace(self, new_conn_wrapper):
def _retry(cls, f):
def new_f(self, *args, **kwargs):
self.operation_count += 1
self.info['request'] = {'method':'f', 'args':args, 'kwargs':kwargs}
try:
allow_retries = kwargs.pop('allow_retries', True)
if kwargs.pop('reset', False):
Expand Down
37 changes: 37 additions & 0 deletions tests/test_connection_pooling.py
Expand Up @@ -5,6 +5,8 @@
from nose.tools import assert_raises, assert_equal
from pycassa import ColumnFamily, ConnectionPool, PoolListener, InvalidRequestError,\
NoConnectionAvailable, MaximumRetryException, AllServersUnavailable
from pycassa.cassandra.c10.ttypes import ColumnPath
from pycassa.pool import ConnectionWrapper

_credentials = {'username':'jsmith', 'password':'havebadpass'}

Expand Down Expand Up @@ -463,6 +465,28 @@ def test_queue_failure_with_no_retries(self):

pool.dispose()

def test_queue_failure_connection_info(self):
totest = {}
listener = _TestListenerRequestInfo(totest)
pool = ConnectionPool(pool_size=5, max_overflow=5, recycle=10000,
prefill=True, max_retries=None,
keyspace='PycassaTestKeyspace', credentials=_credentials,
listeners=[listener], use_threadlocal=False,
server_list=['localhost:9160'])

connection_wrapper = ConnectionWrapper(pool, None, 'PycassaTestKeyspace', 'localhost:9160')
#close it to force the error
connection_wrapper.close()

cp = ColumnPath('Standard1', column='1')

try:
connection_wrapper.get('greunt', cp, 1)
except MaximumRetryException:
pass
print totest
self.assertTrue('request' in totest['dic']['connection'].info)


class _TestListener(PoolListener):

Expand Down Expand Up @@ -512,3 +536,16 @@ def pool_disposed(self, dic):

def pool_at_max(self, dic):
self.max_count += 1


class _TestListenerRequestInfo(_TestListener):
""""""

def __init__(self, totest):
"""Constructor for _TestListenerRequestInfo"""
super(_TestListenerRequestInfo, self).__init__()
self.totest = totest

def connection_failed(self, dic):
super(_TestListenerRequestInfo, self).connection_failed(dic)
self.totest['dic'] = dic

0 comments on commit 2d4c31e

Please sign in to comment.