0
from pykafka import KafkaClient

client = KafkaClient(hosts='192.168.199.87:9092') 

topics = client.topics
print(topics)

the result of topics is a dict with all values are None:

{b'user_name_topic': None, b'test_topic': None}

how to fix it?

eagle A
  • 107
  • 8
  • And what's the issue? You're asking Kafka to give you the list of topics but you get a dict whose keys are the topic. Is this what troubles you? – FrankBr Jun 19 '17 at 07:22
  • @FrankBr yes, it is same as [issue] (https://github.com/Parsely/pykafka/issues/670) – eagle A Jul 31 '17 at 01:15

2 Answers2

0

i fix it in py3:

topic = client.topics[b'test']

client.topics don't return a available dict bescause the weak references

eagle A
  • 107
  • 8
0

See this GitHub issue for an overview of why this happens. It's not a bug, just a strange byproduct of PyKafka's use of weak references to Topic instances.

Emmett Butler
  • 5,969
  • 2
  • 29
  • 47