Skip to content

Commit 9188385

Browse files
committed
Fix ElectionNotNeededError handling in admin client
1 parent be9dd7c commit 9188385

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kafka/admin/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from kafka.coordinator.protocol import ConsumerProtocolMemberMetadata, ConsumerProtocolMemberAssignment, ConsumerProtocol
1616
import kafka.errors as Errors
1717
from kafka.errors import (
18-
IncompatibleBrokerVersion, KafkaConfigurationError, NotControllerError, UnknownTopicOrPartitionError,
18+
IncompatibleBrokerVersion, KafkaConfigurationError, UnknownTopicOrPartitionError,
1919
UnrecognizedBrokerVersion, IllegalArgumentError)
2020
from kafka.metrics import MetricConfig, Metrics
2121
from kafka.protocol.admin import (
@@ -411,7 +411,7 @@ def _parse_topic_request_response(self, topic_error_tuples, request, response, t
411411
# extra values (usually the error_message)
412412
for topic, error_code in map(lambda e: e[:2], topic_error_tuples):
413413
error_type = Errors.for_code(error_code)
414-
if tries and error_type is NotControllerError:
414+
if tries and error_type is Errors.NotControllerError:
415415
# No need to inspect the rest of the errors for
416416
# non-retriable errors because NotControllerError should
417417
# either be thrown for all errors or no errors.
@@ -431,13 +431,13 @@ def _parse_topic_partition_request_response(self, request, response, tries):
431431
for topic, partition_results in response.replication_election_results:
432432
for partition_id, error_code in map(lambda e: e[:2], partition_results):
433433
error_type = Errors.for_code(error_code)
434-
if tries and error_type is NotControllerError:
434+
if tries and error_type is Errors.NotControllerError:
435435
# No need to inspect the rest of the errors for
436436
# non-retriable errors because NotControllerError should
437437
# either be thrown for all errors or no errors.
438438
self._refresh_controller_id()
439439
return False
440-
elif error_type not in [Errors.NoError, Errors.ElectionNotNeeded]:
440+
elif error_type not in (Errors.NoError, Errors.ElectionNotNeededError):
441441
raise error_type(
442442
"Request '{}' failed with response '{}'."
443443
.format(request, response))

0 commit comments

Comments
 (0)