Skip to content

Commit

Permalink
fix: Make Client.messages reusable (#312); Close #268
Browse files Browse the repository at this point in the history
* Updating messages iterator
* Updating CHANGELOG
  • Loading branch information
ryan-summers authored Jul 1, 2024
1 parent f2647b2 commit 7b2cce6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 7b2cce6

Please sign in to comment.