diff --git a/kafka/consumer/fetcher.py b/kafka/consumer/fetcher.py index 2f7afa1a6..cfd9bbc64 100644 --- a/kafka/consumer/fetcher.py +++ b/kafka/consumer/fetcher.py @@ -851,7 +851,7 @@ def _parse_fetched_data(self, completed_fetch): elif error_type is Errors.TopicAuthorizationFailedError: log.warning("Not authorized to read from topic %s.", tp.topic) - raise Errors.TopicAuthorizationFailedError(set(tp.topic)) + raise Errors.TopicAuthorizationFailedError(tp.topic) elif error_type is Errors.UnknownError: log.warning("Unknown error fetching data for topic-partition %s", tp) else: diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index f58221372..d8b5291fe 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -697,6 +697,8 @@ def _wait_on_metadata(self, topic, max_wait): self._sender.wakeup() metadata_event.wait(max_wait - elapsed) elapsed = time.time() - begin + if future.exception: + raise future.exception if not metadata_event.is_set(): raise Errors.KafkaTimeoutError( f"Failed to update metadata after {max_wait:.1f} secs.")