Skip to main content

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

import paho.mqtt.client as mqtt
import trio
from trio_paho_mqtt import AsyncClient


async def handle_messages(client):
    async for msg in client.messages():
        print(f"Received msg: {msg}")

async with trio.open_nursery() as nursery:
    sync_client = mqtt.Client()
    client = AsyncClient(sync_client, nursery)
    client.connect('mqtt.eclipse.org', 1883, 60)
    client.subscribe(topic)
    client.publish(topic, msg)

    nursery.start_soon(handle_messages, client)
  • 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.

Metadata

Release files for trio-paho-mqtt 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trio-paho-mqtt 0.3.1
File Size Uploaded Provenance Actions
trio-paho-mqtt-0.3.1.tar.gz 3.8 kB Without provenance Details for trio-paho-mqtt-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trio-paho-mqtt 0.3.1
File Interpreter ABI Platform Actions
trio_paho_mqtt-0.3.1-py3-none-any.whl Python 3 none any Details for trio_paho_mqtt-0.3.1-py3-none-any.whl

Total release size: 11.9 kB

Release files / trio-paho-mqtt-0.3.1.tar.gz

Download URL trio-paho-mqtt-0.3.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4fc416d663856bdeb2beae96d81ee2e82cf98b2cadc8ecc3e033137afacb45ae
BLAKE2b-256 checksum
How to use checksums
80ae363804eca1c5cbc9bceb8a1f79ae46a1db4cfb9180374d7d7a8720c819dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

Release files / trio_paho_mqtt-0.3.1-py3-none-any.whl

Download URL trio_paho_mqtt-0.3.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57405e1ec5b195e6760da9f5a4b1b00e201ec7aed787f6267f6361bf00a63c53
BLAKE2b-256 checksum
How to use checksums
9c6797686043cce5c8e068ef2fb82315b3419215a71fb53a12012ae725cb8fe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

Security for trio-paho-mqtt 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page