Skip to content

'cimpl.Consumer' object has no attribute 'offsets_for_times' #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lea4n opened this issue Jan 24, 2018 · 9 comments
Closed

'cimpl.Consumer' object has no attribute 'offsets_for_times' #304

lea4n opened this issue Jan 24, 2018 · 9 comments
Labels

Comments

@lea4n
Copy link

lea4n commented Jan 24, 2018

Description

When run the examples/integration_test.py , i run into the error.

offsets = c.offsets_for_times(topic_partions_to_search, timeout=1.0)

AttributeError: 'cimpl.Consumer' object has no attribute 'offsets_for_times'

How to reproduce

Checklist

Please provide the following information:

python -c 'from confluent_kafka import version ; print(version())'
('0.11.0', 720896)

@edenhill
Copy link
Contributor

That looks like you are using an old version of confluent-kafka-python and/or librdkafka or that it is picking up a stray cimpl.so from somewhere.
I suggest you upgrade librdkafka and then rebuild the python module from scratch.

@idristarwala
Copy link

I am also facing the same issue:
librdkafka1 is the latest : librdkafka1 is already the newest version (0.9.2~1confluent3.1.2-1).

@edenhill
Copy link
Contributor

edenhill commented Mar 4, 2018

librdkafka 0.9.2 is really old, please upgrade to librdkafka >= v0.11.1.
note: v0.11.4 is due in about two weeks time.

@canyousayyes
Copy link

The implementation of offsets_for_times isn't available until v0.11.4.
The package in pip is only v0.11.0.

So you can either wait for an update from pip, or, if you are impatient like me, you can compile it yourself.

Here's the example commands (tested in docker image python:3.6):

wget -q https://github.com/confluentinc/confluent-kafka-python/archive/v0.11.4rc1.tar.gz -O /tmp/confluent-kafka.tar.gz
tar xzvf /tmp/confluent-kafka.tar.gz -C /tmp
cd /tmp/confluent-kafka-python-0.11.4rc1/
python3 setup.py install

Then, verify by:

python -c 'from confluent_kafka import version ; print(version())'
('0.11.4', 721920)

@edenhill
Copy link
Contributor

edenhill commented Mar 9, 2018

You might be interested to know that in the upcoming v0.11.4 release we'll bundle librdkafka (and its dependencies) in a binary wheel, voiding the need to install librdkafka separately.

There is a release candidate that you can try out (and please report your installation experience), see this comment for instructions: #184 (comment)

@miikmaac
Copy link

miikmaac commented Jun 6, 2018

I am encountering a similar issue with 'subscription':

Traceback (most recent call last):
  File "forecast_engine_seed.py", line 334, in <module>
    main()
  File "forecast_engine_seed.py", line 330, in main
    ForecastEngineSeed()
  File "forecast_engine_seed.py", line 76, in __init__
    self.run()
  File "forecast_engine_seed.py", line 164, in run
    raw_fcst_request = self.subscribe(self.forecast_topic)
  File "forecast_engine_seed.py", line 186, in subscribe
    print(self.c.subscription())
AttributeError: 'cimpl.Consumer' object has no attribute 'subscription'

Output of python -c 'from confluent_kafka import version ; print(version())' is ('0.11.4', 721920). Any way to get this to work? My goal is just to see if the consumer is already subscribed to a topic.

@rnpridgeon
Copy link
Contributor

@miikmaac are you sure you didn't mean to use subscribe

The method subscription does not appear in the PyMethodDef for the consumer in master

https://github.com/confluentinc/confluent-kafka-python/blob/master/confluent_kafka/src/Consumer.c#L997-L1269

As denoted by the leading underscore the attribute _EXISTING_SUBSCRIPTION is meant for internal use only.

Perhaps you are actually looking to execute consumer.assignment() which returns the current consumer instance's assignment list.

@miikmaac
Copy link

miikmaac commented Jun 6, 2018

@rnpridgeon Thanks - I guess I was looking at the wrong docs, these are the ones I was going off of: https://kafka-python.readthedocs.io/en/latest/apidoc/KafkaConsumer.html

@rnpridgeon
Copy link
Contributor

@miikmaac understood, that's actually a different client despite the deceptively similar name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants