diff options
-rw-r--r-- | kafka/conn.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kafka/conn.py b/kafka/conn.py index 471bae7..4d56964 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -357,6 +357,13 @@ class BrokerConnection(object): ret = self._sock.connect_ex(self._sock_addr) except socket.error as err: ret = err.errno + except ValueError as err: + # Python 3.7 and higher raises ValueError if a socket + # is already connected + if sys.version_info >= (3, 7): + ret = None + else: + raise # Connection succeeded if not ret or ret == errno.EISCONN: |