diff options
author | Jeff Widman <jeff@jeffwidman.com> | 2018-05-10 16:12:19 -0700 |
---|---|---|
committer | Jeff Widman <jeff@jeffwidman.com> | 2018-05-10 16:14:59 -0700 |
commit | c9fba2041e138b49c85a566c2ff80cf5af91a4e8 (patch) | |
tree | fd03145aa7897175627b351715833a17093d1903 /kafka/client.py | |
parent | 27f939ad528a5f7f71346c3d9b18e1a9aa9404e5 (diff) | |
download | kafka-python-Stop-shadowing-native-python-ConnectionError-exception.tar.gz |
Stop shadowing `ConnectionError`Stop-shadowing-native-python-ConnectionError-exception
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.
Diffstat (limited to 'kafka/client.py')
-rw-r--r-- | kafka/client.py | 12 |
1 files changed, 6 insertions, 6 deletions
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: |