Skip to content

Unclosed consumer and producer warnings when using AsyncContextManager interface #1130

@calgray

Description

@calgray

Describe the bug
Consumers and Producers when __aenter__() errors (such as network-related exceptions) leaves the object in a state requiring an explicit close() call.

Context manager interfaces via the "with" keyword do not invoke __aclose__() if entering failed.

Expected behaviour
__aenter__() and start() if an exception raises put the object back into an "unentered" state, and potentially allow trying again later.

Environment (please complete the following information):

  • aiokafka version (python -c "import aiokafka; print(aiokafka.__version__)"): 0.12.0
  • Kafka Broker version (kafka-topics.sh --version): 2.8.1

Reproducible example
See Fork Commit

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