diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b7cd866..cd292fdd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,9 @@ Bug Fixes --------- * Don't strip trailing underscores from column names when using the named_tuple_factory (PYTHON-56) +* Pass WriteType instance to RetryPolicy.on_write_timeout() instead + of the string name of the write type. This caused write timeout + errors to always be rethrown instead of retrying. (github #123) 1.1.2 ===== diff --git a/cassandra/decoder.py b/cassandra/decoder.py index 0a014bd3..0e8d23ea 100644 --- a/cassandra/decoder.py +++ b/cassandra/decoder.py @@ -43,6 +43,7 @@ from cassandra.cqltypes import (AsciiType, BytesType, BooleanType, InetAddressType, IntegerType, ListType, LongType, MapType, SetType, TimeUUIDType, UTF8Type, UUIDType, lookup_casstype) +from cassandra.policies import WriteType log = logging.getLogger(__name__) @@ -291,7 +292,7 @@ class WriteTimeoutErrorMessage(RequestExecutionException): 'consistency': read_consistency_level(f), 'received_responses': read_int(f), 'required_responses': read_int(f), - 'write_type': read_string(f), + 'write_type': WriteType.name_to_value[read_string(f)], } def to_exception(self): diff --git a/cassandra/policies.py b/cassandra/policies.py index 2d538c2d..c1445743 100644 --- a/cassandra/policies.py +++ b/cassandra/policies.py @@ -568,6 +568,14 @@ class WriteType(object): internally before a BATCH write. """ +WriteType.name_to_value = { + 'SIMPLE': WriteType.SIMPLE, + 'BATCH': WriteType.BATCH, + 'UNLOGGED_BATCH': WriteType.UNLOGGED_BATCH, + 'COUNTER': WriteType.COUNTER, + 'BATCH_LOG': WriteType.BATCH_LOG, +} + class RetryPolicy(object): """