pykafka.client

Author: Keith Bourgoin, Emmett Butler

class pykafka.client.KafkaClient(hosts='127.0.0.1:9092', use_greenlets=False, socket_timeout_ms=30000, offsets_channel_socket_timeout_ms=10000, ignore_rdkafka=False, exclude_internal_topics=True)

Bases: object

A high-level pythonic client for Kafka

__init__(hosts='127.0.0.1:9092', use_greenlets=False, socket_timeout_ms=30000, offsets_channel_socket_timeout_ms=10000, ignore_rdkafka=False, exclude_internal_topics=True)

Create a connection to a Kafka cluster.

Parameters:
  • hosts (str) – Comma-separated list of kafka hosts to used to connect.
  • use_greenlets (bool) – If True, use gevent instead of threading.
  • socket_timeout_ms (int) – The socket timeout (in milliseconds) for network requests
  • offsets_channel_socket_timeout_ms (int) – The socket timeout (in milliseconds) when reading responses for offset commit and offset fetch requests.
  • ignore_rdkafka (bool) – Don’t use rdkafka, even if installed.
  • exclude_internal_topics (bool) – Whether messages from internal topics (specifically, the offsets topic) should be exposed to the consumer.
__weakref__

list of weak references to the object (if defined)

update_cluster()

Update known brokers and topics.

Updates each Topic and Broker, adding new ones as found, with current metadata from the cluster.