From c9fba2041e138b49c85a566c2ff80cf5af91a4e8 Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Thu, 10 May 2018 16:12:19 -0700 Subject: Stop shadowing `ConnectionError` In Python3, `ConnectionError` is a native exception. So rename our custom one to `KafkaConnectionError` to prevent accidentally shadowing the native one. Note that there are still valid uses of `ConnectionError` in this code. They already expect a native Python3 `ConnectionError`, and also already handle the Python2 compatibility issues. --- kafka/client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'kafka/client.py') diff --git a/kafka/client.py b/kafka/client.py index 10b1724..789d4da 100644 --- a/kafka/client.py +++ b/kafka/client.py @@ -11,7 +11,7 @@ import select from kafka.vendor import six import kafka.errors -from kafka.errors import (UnknownError, ConnectionError, FailedPayloadsError, +from kafka.errors import (UnknownError, KafkaConnectionError, FailedPayloadsError, KafkaTimeoutError, KafkaUnavailableError, LeaderNotAvailableError, UnknownTopicOrPartitionError, NotLeaderForPartitionError, ReplicaNotAvailableError) @@ -73,7 +73,7 @@ class SimpleClient(object): conn = self._conns[host_key] if not conn.connect_blocking(self.timeout): conn.close() - raise ConnectionError("%s:%s (%s)" % (host, port, afi)) + raise KafkaConnectionError("%s:%s (%s)" % (host, port, afi)) return conn def _get_leader_for_partition(self, topic, partition): @@ -156,7 +156,7 @@ class SimpleClient(object): for (host, port, afi) in hosts: try: conn = self._get_conn(host, port, afi) - except ConnectionError: + except KafkaConnectionError: log.warning("Skipping unconnected connection: %s:%s (AFI %s)", host, port, afi) continue @@ -242,7 +242,7 @@ class SimpleClient(object): host, port, afi = get_ip_port_afi(broker.host) try: conn = self._get_conn(host, broker.port, afi) - except ConnectionError: + except KafkaConnectionError: refresh_metadata = True failed_payloads(broker_payloads) continue @@ -344,8 +344,8 @@ class SimpleClient(object): try: host, port, afi = get_ip_port_afi(broker.host) conn = self._get_conn(host, broker.port, afi) - except ConnectionError as e: - log.warning('ConnectionError attempting to send request %s ' + except KafkaConnectionError as e: + log.warning('KafkaConnectionError attempting to send request %s ' 'to server %s: %s', request_id, broker, e) for payload in payloads: -- cgit v1.2.1