8000 If consumer isn't started, `getmany()` fails with `AttributeError` · Issue #1102 · aio-libs/aiokafka · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
If consumer isn't started, getmany() fails with AttributeError #1102
Open
@MrCreosote

Description

@MrCreosote

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0