summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Beebe <erik@beebe.cc>2016-05-17 09:04:05 -0500
committerDana Powers <dana.powers@gmail.com>2016-05-17 07:04:05 -0700
commitd7fa0731a0aba7cb59addbbc9f6f3b270a842df7 (patch)
treeb45567a1afb9ee40f04cb19307d880d0a6975b61
parenta7e9dfc405d5d1de60ce15bc6dad016d6418e3aa (diff)
downloadkafka-python-d7fa0731a0aba7cb59addbbc9f6f3b270a842df7.tar.gz
supplement socket.gaierror exception in BrokerConnection.connect() (#687)
supplement socket.gaierror exception to include the host/port
-rw-r--r--kafka/conn.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/kafka/conn.py b/kafka/conn.py
index 5cfc7f7..8f0539b 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -115,9 +115,16 @@ class BrokerConnection(object):
# library like python-adns, or move resolution onto its
# own thread. This will be subject to the default libc
# name resolution timeout (5s on most Linux boxes)
- self._gai = socket.getaddrinfo(self.host, self.port,
- socket.AF_UNSPEC,
- socket.SOCK_STREAM)
+ try:
+ self._gai = socket.getaddrinfo(self.host, self.port,
+ socket.AF_UNSPEC,
+ socket.SOCK_STREAM)
+ except socket.gaierror as ex:
+ raise socket.gaierror('getaddrinfo failed for {0}:{1}, '
+ 'exception was {2}. Is your advertised.host.name correct'
+ ' and resolvable?'.format(
+ self.host, self.port, ex
+ ))
self._gai_index = 0
else:
# if self._gai already exists, then we should try the next