Skip to main content

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

Project description

PyMosquitto

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

Dependencies

  • python3.8+
  • libmosquitto1

Installation

  • pip install pymosquitto

Usage

from pymosquitto.client import MQTTClient


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


client = MQTTClient()
client.on_connect = lambda *_: client.subscribe("#", 1)
client.on_message = on_message
client.connect_async("localhost", 1883)
client.loop_forever()

Check out more examples in tests/test_client.py.

Benchmarks

Receiving 1 million messages with QoS 0.

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

benchmark-results

Losers excluded:

benchmark-results-fast

benchmark.csv

Module;Time;RSS
pymosq;0:04.42;17384
paho;0:09.50;23048
gmqtt;0:04.83;24848
aiomqtt;0:53.68;573284
amqtt;0;0

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymosquitto-0.1.6.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymosquitto-0.1.6-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file pymosquitto-0.1.6.tar.gz.

File metadata

  • Download URL: pymosquitto-0.1.6.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymosquitto-0.1.6.tar.gz
Algorithm Hash digest
SHA256 effcfa961f8bae479bc6ad85ff144e31784b9f06acceddd7b5fb7bf53f9aaf92
MD5 b984da796ad89587108773014dd0923f
BLAKE2b-256 1169c2b7d0f178f1670cc5ac7ea49d9c2b6f6e4ad5a11291a656fa25e226a0ca

See more details on using hashes here.

File details

Details for the file pymosquitto-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pymosquitto-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymosquitto-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 823e1c6a32c3d7dbca9e1d23eab75e7380e51959c443eedec65f543626e1799f
MD5 0f28144ce43e55fe8410210bf799c49c
BLAKE2b-256 941f0fc01e0607381047d1b48640e85d06a050d03a6ecd2f860cf02fe31c476d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page