Skip to content

Missing async iterator in FakeAIOKafkaConsumer #224

@AMelacini

Description

@AMelacini

In order to be aligned with AIOKafkaConsumer, it would be nice to able to do:

consumer = FakeAIOKafkaConsumer()

# ... some code ...

async for msg in consumer:
    do_process(msg)

This should be the pseudocode of all we need in file mockafka/aiokafka/aiokafka_consumer.py

class FakeAIOKafkaConsumer:
    # ....
    def __aiter__(self):
        return self

    async def __anext__(self):
        msg = await self.getone(...)
        if msg is not None:
            return msg

        # not sure we need to worry about  raise StopAsyncIteration

Just a thought...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions