fix: bound MQTT shutdown publish waits - #154
Draft
robjarawan wants to merge 2 commits into
Draft
Conversation
Test Results377 tests 376 ✅ 1m 44s ⏱️ Results for commit 30c545d. |
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.
Fixes #48.
MQTT.close()waits whilepending_publishesis non-empty, but the current loop has no deadline. I reproduced it with the real MQTT v5/QoS 1 publisher and a local Mosquitto broker. The broker completion reached Paho's callback thread, one MID remained in Sarracenia's pending state, and shutdown was still blocked after the bounded 1.5 second probe even withtimeout=0.25. The normal completion control closed immediately.So what I did was bound the drain with a
time.monotonic()deadline. Normal completions can still drain during the wait. If the deadline expires, the code logs the unresolved MIDs at error level, incrementstxBadCountonce per unresolved MID, then disconnects and stops the Paho loop. An explicittimeout=0is honored without sleeping; only a missing orNonetimeout uses the 300 second default.The real failure case now returns after 0.252 seconds with MID
1still visible for diagnosis. The normal broker control still returns immediately.developmenttests/sarracenia/mothtestsgit diff --checkThis refresh supersedes the closed fork PR #124. MetPX#1650 remains open upstream and is not part of this fork PR. I kept the disconnected-client path and a dedicated close-timeout option outside this fix because they have separate behavior and test boundaries.
This branch also carries the separate local-fixture CI repair from #140 so the fork checks do not depend on public feeds.