Skip to content

Add context manager support to Consumers and producers #1101

Open
@lyytinen

Description

@lyytinen

Would it make sense for the consumers and producers to implement the context management protocol?
So that one could write:

from kafka import KafkaProducer
with KafkaProducer(bootstrap_servers='localhost:1234') as producer:
    for _ in range(100):
        producer.send('foobar', b'some_message_bytes')

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions