confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

AttributeError: 'NoneType' object has no attribute value

Open srinivas1012 opened this issue 2 years ago • 2 comments

I am simply trying to read messages from Kafka partition in a topic. Here is my code:

partition = 1
par=1
    #msg = consumer.poll(1.0)
partition = TopicPartition(topic, partition)
consumer.assign([partition])
offset_tuple=consumer.get_watermark_offsets(partition)
offset=offset_tuple[0]
print(offset)
#print(consumer.get_watermark_offsets(partition)[0])
partition1 = TopicPartition(topic, par,offset)
consumer.assign([partition1])
consumer.seek(partition1)
print(consumer.position([partition1]) )
msg = consumer.poll(1000000000.0)
print(msg.value())

I get an error - AttributeError: 'NoneType' object has no attribute value I am using kafka python version 1.6.0 @edenhill and others, Can someone help me please? I am not sure why I am getting this error message?

srinivas1012 avatar Aug 26 '23 15:08 srinivas1012

consumer.poll returns None on timeout. Can you make sure that there are messages in the topic and you are not hitting the timeout?

pranavrth avatar Aug 29 '23 09:08 pranavrth

@srinivas1012 wanted to follow up based on @pranavrth 's last comment, is this still an issue you are facing? If not please advise so we can close this issue

nhaq-confluent avatar Feb 12 '24 20:02 nhaq-confluent