Repository navigation
feat(amgi-paho-mqtt): add message send manager - #124
Merged
Merged
Conversation
Documentation build overview
3 files changed± specifications/bindings.html± specifications/lifespan.html± specifications/message.html |
There was a problem hiding this comment.
🟡 Changes recommended
Connection and publish failures can leave sender initialization or in-flight publishes hanging indefinitely.
1 open finding
What changed in this PR
Adds portable MQTT message-sender support with injectable lifecycle management.
Changes:
- Introduces
MessageSendand shared asynchronous MQTT client-loop handling. - Adds sender injection and a CLI-safe wrapper.
- Adds unit/integration coverage and Python 3.10 typing support.
| File | Description |
|---|---|
uv.lock |
Locks the conditional typing dependency. |
test_mqtt_message.py |
Tests send dispatch and initialization requirements. |
test_mqtt_message_integration.py |
Tests sender injection, lifecycle, and CLI execution. |
amgi_paho_mqtt/__init__.py |
Implements portable sending and lifecycle integration. |
pyproject.toml |
Adds typing support and updates the CLI entry point. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
TomKimber
force-pushed
the
feat/add-paho-mqtt-message-send-manager
branch
from
October 9, 2026 23:58
e7246c2 to
ab15597
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TomKimber
force-pushed
the
feat/add-paho-mqtt-message-send-manager
branch
2 times, most recently
from
October 10, 2026 19:32
c0321e3 to
148770e
Compare
TomKimber
force-pushed
the
feat/add-paho-mqtt-message-send-manager
branch
5 times, most recently
from
October 10, 2026 20:36
622ce8b to
4a175df
Compare
jackburridge
approved these changes
Oct 12, 2026
TomKimber
force-pushed
the
feat/add-paho-mqtt-message-send-manager
branch
from
October 13, 2026 20:19
4a175df to
ea92f38
Compare
TomKimber
force-pushed
the
feat/add-paho-mqtt-message-send-manager
branch
from
October 13, 2026 20:21
ea92f38 to
d2454ef
Compare
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.


Add Portable Senders support to amgi-paho-mqtt: #72.
This adds a MessageSend async context manager to amgi-paho-mqtt. It handles message.send events on its own paho client and connection instead of reusing the consuming client. It waits for the CONNACK on entry and raises on a broker rejection or a timeout (connect_timeout, default 10s). Each send waits for the broker’s acknowledgement and raises PublishError on failure. The mqtt binding now supports retain as well as qos. With MQTT v5, headers are sent as user properties and content-type maps to the MQTT content type property. MQTT v3.1.1 cannot represent headers, so they are dropped. run() and Server accept an optional message_send manager and connect_timeout.
To share the logic, the asyncio socket, publish and disconnect handling moved out of Server into a _ClientLoop helper that both clients use. It also adds reconnection after unexpected disconnects, which retries every second and logs failures to amgi-paho-mqtt.error. On event loops without add_reader/add_writer, such as the default Proactor loop on Windows, a _SocketWatcher fallback watches the socket from a background thread and runs paho's read and write handlers on the event loop. Previously the package failed on Windows with NotImplementedError. A blocking connect that is abandoned by a timeout or cancellation but later succeeds is now disconnected rather than leaked. The amgi_server entry point now points at a thin _run_cli wrapper, and typing-extensions is added for Python < 3.11. The README has a new “Sending Messages” section, and there are new unit tests plus a broker-backed integration test.
amgi-paho-mqtt is the only gap - Confirmed all other packages have a consistent portable senders implementation.