Author: Keith Bourgoin, Emmett Butler

class pykafka.partition.Partition(topic, id_, leader, replicas, isr)

Bases: object

A Partition is an abstraction over the kafka concept of a partition. A kafka partition is a logical division of the logs for a topic. Its messages are totally ordered.

__init__(topic, id_, leader, replicas, isr)

Instantiate a new Partition

  • topic (pykafka.topic.Topic) – The topic to which this Partition belongs
  • id (int) – The identifier for this partition
  • leader ( – The broker that is currently acting as the leader for this partition.
  • replicas (Iterable of – A list of brokers containing this partition’s replicas
  • isr ( – The current set of in-sync replicas for this partition

list of weak references to the object (if defined)


Get the earliest offset for this partition.

fetch_offset_limit(offsets_before, max_offsets=1)
Use the Offset API to find a limit of valid offsets
for this partition.
  • offsets_before (int) – Return an offset from before this timestamp (in milliseconds)
  • max_offsets (int) – The maximum number of offsets to return

The identifying int for this partition, unique within its topic


The current list of in-sync replicas for this partition


Get the offset of the next message that would be appended to this partition


The broker currently acting as leader for this partition


The list of brokers currently holding replicas of this partition


The topic to which this partition belongs

update(brokers, metadata)

Update this partition with fresh metadata.

  • brokers (List of – Brokers on which partitions exist
  • metadata (pykafka.protocol.PartitionMetadata) – Metadata for the partition