-
Notifications
You must be signed in to change notification settings - Fork 232
Client connects, but topics, listed, have None as their value #670
Comments
Hi @JohnOmernik, and thanks for reaching out. I notice that you're attempting to use a $ kafka-topics.sh --list --zookeeper localhost:2181 |
I see a similar thing when I "list" topics, by just outputting / printing topics:
Once I make use of the topic (creating a consumer/producer), I get the following:
Functionality-wise, it does not seem like anything is wrong. Running the shell script listed gives me:
|
This is happening because of a difference in dict behavior between python 2 and 3. The dict you're examining here is actually a specialized subclass of |
hi, @emmett9001 I use py2 and py3 , but both of them get the same problem: |
@aodiwei Can you be more specific? What code are you running to get the output |
@emmett9001 thx for your answer, sorry for forgetting to replay you
part of console: |
@aodiwei As far as I can tell this is the expected behavior. It's happening due to the use of weak references in the topics dictionary that are not initialized until a call to I can see that this is confusing for more than just a few users, so it's worth considering how to make this interface more readable. Maybe we override |
@emmett9001 thx, i fix it in py3: |
topic exist and both producer and consumer are working for that topic but it show "None" for topic object? I have tried adding
|
@fighting-dreamer This error is happening because by the time you examine |
@emmett9001 thnx!, It is now running |
PyKafka version:pykafka-2.5.0
Kafka version: kafka 0.10.2
I can connect via ZK or direct connection and I get a KafkaClient object back. I can list topics, but they show as "None" value so when I try to "assign" a topic, I get the error below.
<class 'pykafka.client.KafkaClient'>
{b'weblogs': None, b'dnslogs': None}
Traceback (most recent call last):
File "./pyweblogs.py", line 13, in
weblogs = client.topics['weblogs']
File "/usr/local/lib/python3.5/dist-packages/pykafka/cluster.py", line 56, in getitem
"got '%s'", type(key))
TypeError: ("TopicDict.getitem accepts a bytes object, but it got '%s'", <class 'str'>)
The text was updated successfully, but these errors were encountered: