Repository navigation
Conversation
loop_read previously overwrote the caller-supplied max_packets with the count of in-flight QoS > 0 messages, so QoS 0 traffic always processed one packet per call. Use max(caller value, pending, 1) instead so the default of 1 keeps historical behaviour while callers such as Home Assistant can batch reads. Closes eclipse-paho#962 Signed-off-by: Eryx-Z <Eryx-Z@users.noreply.github.com>
Author
|
Closing for now; may revisit later. |
Contributor
|
@Eryx-Z It's your decision, but LGTM. At first glance, your fix looks like exactly the correct one (in my opinion): Replace: max_packets = len(self._out_messages) + len(self._in_messages)
if max_packets < 1:
max_packets = 1with: pending = len(self._out_messages) + len(self._in_messages)
max_packets = max(max_packets, pending, 1)Why is anything more than that required? Is something else using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Client.loop_read(max_packets=...)previously overwrote the caller-supplied bound withlen(_out_messages) + len(_in_messages). For QoS 0 traffic that sum is usually 0, so every call handled exactly one packet regardless of the argument.Home Assistant and similar asyncio integrations call
loop_read(500)expecting to batch available packets. This change usesmax(max_packets, pending, 1)so:1keeps historical QoS 0 behaviourTesting
Added
test_loop_read_honours_max_packets(fake broker, five QoS 0 PUBLISH packets,loop_read(10)receives all five).Closes #962