Fork of trio-paho-mqtt to update it
Go to file
Olivier 'reivilibre' fe399cabea v0.4.1 2022-08-25 17:01:42 +01:00
scripts-dev Rearrange project and add linters 2022-08-25 11:53:38 +01:00
trio_paho_mqtt Fix type annotations 2022-08-25 17:01:39 +01:00
.gitignore Add type annotations 2022-08-25 12:03:20 +01:00
LICENSE Initial commit 2019-12-04 15:08:35 -05:00
README.md Fixes after publishing 2022-08-25 16:14:27 +01:00
example.py Fix demo server name in example 2022-08-25 15:56:24 +01:00
mypy.ini Rearrange project and add linters 2022-08-25 11:53:38 +01:00
poetry.lock Rearrange project and add linters 2022-08-25 11:53:38 +01:00
pyproject.toml v0.4.1 2022-08-25 17:01:42 +01:00

README.md

trio_paho_mqtt

trio specific async MQTT client. The goal of this project is to have all the MQTT protocol stuff handled by paho-mqtt, while the async loopy stuff is handled by trio. This keeps our MQTT communication async, without having to shove paho-mqtt into a thread, and without having to reimplement the MQTT protocol.

All callbacks are also removed to be more trio-like. Messages are accessed through an async for loop.

This is meant to be a light-as-possible wrapper around paho-mqtt. That way if something goes wrong with MQTT message parsing, it's not my fault ;-)

Usage

First, see the example.py and paho-mqtt documentation. The goal is to expose all the same methods as the paho-mqtt Client. If any methods (besides callbacks) are missing or do something unexpected, this is a bug. Please open an issue.

AsyncClient is initialized with a sync mqtt.Client and a trio.Nursery but then otherwise should operate much like the sync Client. Methods are not coroutines, they are non-blocking functions, so you do not need to call await. The only exception is accessing messages through async for.

Example

Please see example.py for a working example! (example in README removed because it was not working)

  • gmqtt - Uses asyncio and callbacks. Isn't compatible with trio.
  • hbmqtt - Uses asyncio. Reimplements the MQTT protocol.
  • aiomqtt - Uses asyncio and wraps paho, but still uses the loop from paho-mqtt. I believe all operations are put into a worker thread.
  • distmqtt - anyio-ified hbmqtt fork. Works with trio.
  • asyncio-mqtt - Same idea as this lib (a light wrapper for paho mqtt), but for asyncio.