diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5e809..c6533d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed +* Fixed an issue where iterating over received messages would yield nothing after the first +iteration. + ## [2.1.0] - 2024-04-24 ### Changed diff --git a/aiomqtt/client.py b/aiomqtt/client.py index b88672c..c59ef8e 100644 --- a/aiomqtt/client.py +++ b/aiomqtt/client.py @@ -238,7 +238,6 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915 if max_queued_incoming_messages is None: max_queued_incoming_messages = 0 self._queue = queue_type(maxsize=max_queued_incoming_messages) - self.messages = self._messages() # Semaphore to limit the number of concurrent outgoing calls self._outgoing_calls_sem: asyncio.Semaphore | None @@ -321,6 +320,10 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915 timeout = 10 self.timeout = timeout + @property + def messages(self) -> AsyncGenerator[Message, None]: + return self._messages() + @property def identifier(self) -> str: """Return the client identifier.