We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 356bf0a commit 1fe644bCopy full SHA for 1fe644b
examples/mqtt/pub_sub.py
@@ -6,10 +6,10 @@
6
7
async def main() -> None:
8
config = enapter.mqtt.Config(host="127.0.0.1", port=1883)
9
- async with enapter.mqtt.Client(config=config) as client:
10
- async with asyncio.TaskGroup() as tg:
11
- tg.create_task(subscriber(client))
12
- tg.create_task(publisher(client))
+ async with asyncio.TaskGroup() as tg:
+ client = enapter.mqtt.Client(tg, config=config)
+ tg.create_task(subscriber(client))
+ tg.create_task(publisher(client))
13
14
15
async def subscriber(client: enapter.mqtt.Client) -> None:
@@ -28,4 +28,7 @@ async def publisher(client: enapter.mqtt.Client) -> None:
28
29
30
if __name__ == "__main__":
31
- asyncio.run(main())
+ try:
32
+ asyncio.run(main())
33
+ except KeyboardInterrupt:
34
+ pass
0 commit comments