Skip to content

If consumer isn't started, getmany() fails with AttributeError #1102

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

Open
MrCreosote opened this issue Mar 27, 2025 · 0 comments
Open

If consumer isn't started, getmany() fails with AttributeError #1102

MrCreosote opened this issue Mar 27, 2025 · 0 comments

Comments

@MrCreosote
Copy link

MrCreosote commented Mar 27, 2025

Describe the bug
If a consumer is created but not started and the genmany() method is called, an AttributeError results.

Expected behaviour
A user friendly error that explains the problem should be thrown.

Environment (please complete the following information):

  • aiokafka version: 0.12.0
  • Kafka Broker version: 3.9.0
  • Other information (Confluent Cloud version, etc.): n/a

Reproducible example

async def err_on_genmany():
    kc = AIOKafkaConsumer(
        "topichere",
        bootstrap_servers=f"localhost:9092",
        auto_offset_reset="earliest"
    )
    await kc.getmany()
    kc.stop()


if __name__ == "__main__":
    asyncio.run(err_on_genmany())

Results in the output:

Traceback (most recent call last):
  File "/home/<user>test_manual/kafka_notifier_manual_test.py", line 130, in <module>
    asyncio.run(err_on_genmany())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/<user>test_manual/kafka_notifier_manual_test.py", line 121, in err_on_genmany
    await kc.getmany()
  File "/home/<user>/.local/share/virtualenvs/<dir>-2sgYN4mf/lib/python3.11/site-packages/aiokafka/consumer/consumer.py", line 1208, in getmany
    self._coordinator.check_errors()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'check_errors'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant