Files
flucto-heisskleber/tests/integration/integration_joint.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

28 lines
757 B
Python

import asyncio
from heisskleber.mqtt import AsyncMqttSubscriber, MqttConf
from heisskleber.stream import Joint, Resampler, ResamplerConf
async def main():
topics = ["topic0", "topic1", "topic2", "topic3"]
config = MqttConf(host="localhost", port=1883, user="", password="") # not a real password
subs = [AsyncMqttSubscriber(config, topic=topic) for topic in topics]
resampler_config = ResamplerConf(resample_rate=1000)
joint = Joint(resampler_config, [Resampler(resampler_config, sub) for sub in subs])
while True:
data = await joint.receive()
print(data)
# Run the event loop
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("Keyboard Interrupt")