summaryrefslogtreecommitdiff
path: root/kafka/conn.py
diff options
context:
space:
mode:
authormrtheb <mrlabbe@gmail.com>2014-02-15 13:43:56 -0500
committermrtheb <mrlabbe@gmail.com>2014-02-15 13:43:56 -0500
commit51910f981843dfa967d24659cdb46117210c832d (patch)
tree76a08c96f45a62495878cf6870dac84603291217 /kafka/conn.py
parenta2191e5be5d5fcd212582580c163f4533cca6c73 (diff)
downloadkafka-python-51910f981843dfa967d24659cdb46117210c832d.tar.gz
clean up after comments from @rdiomar
Diffstat (limited to 'kafka/conn.py')
-rw-r--r--kafka/conn.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/kafka/conn.py b/kafka/conn.py
index 20f22dc..749cc02 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -10,6 +10,8 @@ from kafka.common import ConnectionError
log = logging.getLogger("kafka")
DEFAULT_SOCKET_TIMEOUT_SECONDS = 120
+DEFAULT_KAFKA_PORT = 9092
+
def collect_hosts(hosts, randomize=True):
"""
@@ -18,14 +20,14 @@ def collect_hosts(hosts, randomize=True):
"""
if isinstance(hosts, str):
- hosts = hosts.split(',')
+ hosts = hosts.strip().split(',')
result = []
for host_port in hosts:
res = host_port.split(':')
host = res[0]
- port = int(res[1]) if len(res) > 1 else 9092
+ port = int(res[1]) if len(res) > 1 else DEFAULT_KAFKA_PORT
result.append((host.strip(), port))
if randomize:
@@ -105,7 +107,7 @@ class KafkaConnection(local):
sent = self._sock.sendall(payload)
if sent is not None:
self._raise_connection_error()
- except socket.error, e:
+ except socket.error:
log.exception('Unable to send payload to Kafka')
self._raise_connection_error()