Skip to content

Commit ae684f0

Browse files
committed
Pass WriteType, not str to RetryPolicy.on_write_timeout
Fixes #123
1 parent 8908600 commit ae684f0

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Bug Fixes
1010
---------
1111
* Don't strip trailing underscores from column names when using the
1212
named_tuple_factory (PYTHON-56)
13+
* Pass WriteType instance to RetryPolicy.on_write_timeout() instead
14+
of the string name of the write type. This caused write timeout
15+
errors to always be rethrown instead of retrying. (github #123)
1316

1417
1.1.2
1518
=====

cassandra/decoder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
InetAddressType, IntegerType, ListType,
4444
LongType, MapType, SetType, TimeUUIDType,
4545
UTF8Type, UUIDType, lookup_casstype)
46+
from cassandra.policies import WriteType
4647

4748
log = logging.getLogger(__name__)
4849

@@ -291,7 +292,7 @@ def recv_error_info(f):
291292
'consistency': read_consistency_level(f),
292293
'received_responses': read_int(f),
293294
'required_responses': read_int(f),
294-
'write_type': read_string(f),
295+
'write_type': WriteType.name_to_value[read_string(f)],
295296
}
296297

297298
def to_exception(self):

cassandra/policies.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ class WriteType(object):
568568
internally before a BATCH write.
569569
"""
570570

571+
WriteType.name_to_value = {
572+
'SIMPLE': WriteType.SIMPLE,
573+
'BATCH': WriteType.BATCH,
574+
'UNLOGGED_BATCH': WriteType.UNLOGGED_BATCH,
575+
'COUNTER': WriteType.COUNTER,
576+
'BATCH_LOG': WriteType.BATCH_LOG,
577+
}
578+
571579

572580
class RetryPolicy(object):
573581
"""

0 commit comments

Comments
 (0)