Skip to content

Commit c49ae90

Browse files
jeffwidmandpkp
authored andcommitted
Raise non-API exceptions (dpkp#1316)
The original intent was to catch API exceptions (errors returned by the broker when trying to produce a message) and delegate them to the messages' futures. This is copied from the Java producer. However, we were accidentally catching all exceptions, thereby hiding exceptions from users unless they explicitly check the result of the future. Much better to raise client-side errors directly in the foreground so the user is immediately aware of them and can decide how to handle. Fix dpkp#1274
1 parent ad024d1 commit c49ae90

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

kafka/producer/kafka.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,7 @@ def send(self, topic, value=None, key=None, partition=None, timestamp_ms=None):
571571
# handling exceptions and record the errors;
572572
# for API exceptions return them in the future,
573573
# for other exceptions raise directly
574-
except Errors.KafkaTimeoutError:
575-
raise
576-
except AssertionError:
577-
raise
578-
except Exception as e:
574+
except Errors.BrokerResponseError as e:
579575
log.debug("Exception occurred during message send: %s", e)
580576
return FutureRecordMetadata(
581577
FutureProduceResult(TopicPartition(topic, partition)),

0 commit comments

Comments
 (0)