Skip to main content

ctypes-mosquitto

A lightweight Python MQTT client implemented as a thin wrapper around libmosquitto.

Dependencies

  • python3.8+
  • libmosquitto1

Installation

  • pip install ctypes-mosquitto

Usage

from ctypes_mosquitto import Mosquitto


def on_message(client, userdata, msg):
    print(msg)


client = Mosquitto()
client.connect_callback_set(lambda *_: client.subscribe("#", qos=1))
client.message_callback_set(on_message)
client.connect_async("localhost", 1883)
client.loop_forever()

Async client example:

import asyncio

from ctypes_mosquitto.aio import AIO
from ctypes_mosquitto import Mosquitto


async def main():
    async with AIO(Mosquitto()) as client:
        await client.connect("localhost", 1883)
        await client.subscribe("#", 1)
        async for msg in client.read_messages():
            print(msg)


asyncio.run(main())

Check out more examples in tests directory.

Benchmarks

Receiving one million messages with QoS 0.

*The memory plots exclude the Python interpreter overhead (~10 MB).

benchmark-results

Losers excluded:

benchmark-results-fast

benchmark.csv

Module;Time;RSS
ctypes_mosq;4.44;7900
ctypes_mosq_async;8.54;14672
paho;8.74;13004
gmqtt;3.54;12136
mqttools;11.39;15716
aiomqtt;147.40;302936
amqtt;90.32;469020

License

MIT

Metadata

Release files for ctypes-mosquitto 0.2.0

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

Source distribution (sdist)

Source distribution for ctypes-mosquitto 0.2.0
File Size Uploaded Provenance Actions
ctypes_mosquitto-0.2.0.tar.gz 17.4 kB Without provenance Details for ctypes_mosquitto-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ctypes-mosquitto 0.2.0
File Interpreter ABI Platform Actions
ctypes_mosquitto-0.2.0-py3-none-any.whl Python 3 none any Details for ctypes_mosquitto-0.2.0-py3-none-any.whl

Total release size: 33.7 kB

Release files / ctypes_mosquitto-0.2.0.tar.gz

Download URL ctypes_mosquitto-0.2.0.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aa4c37acf036502023970190bd8fd0200079e871a934c77419758d02adccd5f6
BLAKE2b-256 checksum
How to use checksums
92a12d83c00857c8ab6cc7a4cfafcc575be7cac292df8130bbddde4bb794ff0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / ctypes_mosquitto-0.2.0-py3-none-any.whl

Download URL ctypes_mosquitto-0.2.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d1bb9df98d3d5fc11843e74fe52b6c435fc5acecf5cac055bb3144b89d16a26
BLAKE2b-256 checksum
How to use checksums
cc62b5e9a70ab7fafe8f5433e92aab62889e69b8f95ce59f24c6a6de306a2bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for ctypes-mosquitto 0.2.0

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.2.0 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