diff options
author | Erik Beebe <erik@beebe.cc> | 2016-05-17 09:04:05 -0500 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2016-05-17 07:04:05 -0700 |
commit | d7fa0731a0aba7cb59addbbc9f6f3b270a842df7 (patch) | |
tree | b45567a1afb9ee40f04cb19307d880d0a6975b61 | |
parent | a7e9dfc405d5d1de60ce15bc6dad016d6418e3aa (diff) | |
download | kafka-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.py | 13 |
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 |