Files
flucto-heisskleber/tests/integration/mqtt_async.py
Felix Weiler 8c985bdf3c Refactor/background tasks (#75)
* Add start, stop and __repr__ to sink and source types.

* Merge conflicts on mqtt async pub and resampler.

* Add start() and stop() functions to udp and zmq.

Change tests accordingly.

* Rename broker, ip, interface to common config name "host".

* Updated "host" entry in config files.

* Add lazyload to mqtt-source.
2024-02-22 18:50:13 +08:00

19 lines
455 B
Python

import asyncio
from heisskleber.mqtt import AsyncMqttSubscriber, MqttConf
async def main():
conf = MqttConf(host="localhost", port=1883, user="", password="")
sub = AsyncMqttSubscriber(conf, topic="#")
# async for topic, message in sub:
# print(message)
# _ = asyncio.create_task(sub.run())
while True:
topic, message = await sub.receive()
print(message)
if __name__ == "__main__":
asyncio.run(main())