diff options
author | Mark Roberts <wizzat@gmail.com> | 2014-04-25 10:55:04 -0700 |
---|---|---|
committer | Mark Roberts <wizzat@gmail.com> | 2014-04-25 10:55:04 -0700 |
commit | 57913f9f914a959f52bc9040a172f8c9ff77e491 (patch) | |
tree | fe5cc6c14283a4c9d9175a748ef97f7d55df6fd7 /kafka/util.py | |
parent | 0e50f33ec678f6d656d488ce8a4537f95bba003e (diff) | |
download | kafka-python-57913f9f914a959f52bc9040a172f8c9ff77e491.tar.gz |
Various fixes
Bump version number to 0.9.1
Update readme to show supported Kafka/Python versions
Validate arguments in consumer.py, add initial consumer unit test
Make service kill() child processes when startup fails
Add tests for util.py, fix Python 2.6 specific bug.
Diffstat (limited to 'kafka/util.py')
-rw-r--r-- | kafka/util.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kafka/util.py b/kafka/util.py index 54052fb..0577a88 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -1,5 +1,6 @@ -from collections import defaultdict +import sys import struct +import collections from threading import Thread, Event from kafka.common import BufferUnderflowError @@ -15,6 +16,9 @@ def write_int_string(s): def write_short_string(s): if s is None: return struct.pack('>h', -1) + elif len(s) > 32767 and sys.version < (2,7): + # Python 2.6 issues a deprecation warning instead of a struct error + raise struct.error(len(s)) else: return struct.pack('>h%ds' % len(s), len(s), s) @@ -63,7 +67,7 @@ def relative_unpack(fmt, data, cur): def group_by_topic_and_partition(tuples): - out = defaultdict(dict) + out = collections.defaultdict(dict) for t in tuples: out[t.topic][t.partition] = t return out |