Skip to content
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

Fix: Iterating over received messages multiple times does not yield proper results #312

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion aiomqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down