Skip to content

KafkaProducer.send should raise non-api exceptions (not metadata lookup) #1274

Closed
@tvoinarovskyi

Description

@tvoinarovskyi

After @jeffwidman pointed out in #1272 (comment) that validation errors will not pop up on Producer.send went to the code and found this:

        except Exception as e:
            log.debug("Exception occurred during message send: %s", e)
            return FutureRecordMetadata(
                FutureProduceResult(TopicPartition(topic, partition)),
                -1, None, None,
                len(key_bytes) if key_bytes is not None else -1,
                len(value_bytes) if value_bytes is not None else -1
            ).failure(e)

Ie, we explicitly delegate any errors to the future... Why? I find it very confusing and would just allow the exceptions to be raised to application level right away. @dpkp could you elaborate on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions