summaryrefslogtreecommitdiff
path: root/kafka/producer/simple.py
diff options
context:
space:
mode:
Diffstat (limited to 'kafka/producer/simple.py')
-rw-r--r--kafka/producer/simple.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/kafka/producer/simple.py b/kafka/producer/simple.py
index afeae06..2699cf2 100644
--- a/kafka/producer/simple.py
+++ b/kafka/producer/simple.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
import logging
import random
+import six
from itertools import cycle
@@ -68,8 +69,13 @@ class SimpleProducer(Producer):
return next(self.partition_cycles[topic])
def send_messages(self, topic, *msg):
+ if not isinstance(topic, six.binary_type):
+ topic = topic.encode('utf-8')
+
partition = self._next_partition(topic)
- return super(SimpleProducer, self).send_messages(topic, partition, *msg)
+ return super(SimpleProducer, self).send_messages(
+ topic, partition, *msg
+ )
def __repr__(self):
return '<SimpleProducer batch=%s>' % self.async