diff options
author | Dana Powers <dana.powers@gmail.com> | 2014-05-07 00:04:04 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2014-05-07 00:04:04 -0700 |
commit | b47bf781eb0e96c3fef59cbe554325155062e129 (patch) | |
tree | c74db904c37ba1e70dab6dd2c78f4c1a4abd173f /kafka/util.py | |
parent | 3b18043821f37242bde2b186684fa05d36c61921 (diff) | |
parent | b81bf5f69e24b0d0106693b6e47906669873ec18 (diff) | |
download | kafka-python-b47bf781eb0e96c3fef59cbe554325155062e129.tar.gz |
Merge pull request #158 from wizzat/add_tests
Improve Tests, fix connection error timeout, other issues
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..a918234 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -1,5 +1,6 @@ -from collections import defaultdict +import collections import struct +import sys 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 |