MQTT support for the Trio async runtime using Paho (update fork)
Project description
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)
Related projects
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file trio-paho-mqtt-up1-0.4.1.tar.gz
.
File metadata
- Download URL: trio-paho-mqtt-up1-0.4.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.10.4 Linux/5.17.0-1015-oem
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8cd708dd2cde39679f669579668b21929b1308d618324dcf8fa903cdebb535d |
|
MD5 | c691b0e79c8eb8591e8a895214706a74 |
|
BLAKE2b-256 | 7b788e789ca04f5a009ab2670c4e0b1a1364b8a8a33fe548fa7abea7380bcf62 |
File details
Details for the file trio_paho_mqtt_up1-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: trio_paho_mqtt_up1-0.4.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0b2 CPython/3.10.4 Linux/5.17.0-1015-oem
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ce568585dc96fef57a60898cb7022bb3a20cf0b0a8c82731b5b377d45893ed8 |
|
MD5 | add99cb205bcd57d0b643e8d2731a0a3 |
|
BLAKE2b-256 | 3d6e99b59ac713cad32fb81671103e2b8cb047a600b9509d1970fef8cf894622 |