Skip to content

Commit a6fc260

Browse files
author
Mark Roberts
committed
Merge branch 'master' into conn_refactor
2 parents 888f206 + 9599215 commit a6fc260

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

kafka/client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ def _send_broker_unaware_request(self, requestId, request):
8383
brokers. Keep trying until you succeed.
8484
"""
8585
for (host, port) in self.hosts:
86-
conn = self._get_conn(host, port)
8786
try:
87+
conn = self._get_conn(host, port)
8888
conn.send(requestId, request)
8989
response = conn.recv(requestId)
9090
return response
9191
except Exception, e:
92-
log.warning("Could not send request [%r] to server %s, "
93-
"trying next server: %s" % (request, conn, e))
92+
log.warning("Could not send request [%r] to server %s:%i, "
93+
"trying next server: %s" % (request, host, port, e))
9494
continue
9595

9696
raise KafkaUnavailableError("All servers failed to process request")

kafka/conn.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
def collect_hosts(hosts, randomize=True):
1717
"""
18-
Collects a comma-separated set of hosts (host:port) and optionnaly
18+
Collects a comma-separated set of hosts (host:port) and optionally
1919
randomize the returned list.
2020
"""
2121

22-
if isinstance(hosts, str):
22+
if isinstance(hosts, basestring):
2323
hosts = hosts.strip().split(',')
2424

2525
result = []

test/test_unit.py

+10
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ def test_init_with_csv(self):
449449
[('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)],
450450
client.hosts)
451451

452+
def test_init_with_unicode_csv(self):
453+
454+
with patch.object(KafkaClient, 'load_metadata_for_topics'):
455+
client = KafkaClient(
456+
hosts=u'kafka01:9092,kafka02:9092,kafka03:9092')
457+
458+
self.assertItemsEqual(
459+
[('kafka01', 9092), ('kafka02', 9092), ('kafka03', 9092)],
460+
client.hosts)
461+
452462
def test_send_broker_unaware_request_fail(self):
453463
'Tests that call fails when all hosts are unavailable'
454464

0 commit comments

Comments
 (0)