File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 44import enapter
55
66
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 ))
13+
14+
715async def subscriber (client : enapter .mqtt .Client ) -> None :
816 async with client .subscribe ("/+" ) as messages :
917 async for msg in messages :
@@ -19,13 +27,5 @@ async def publisher(client: enapter.mqtt.Client) -> None:
1927 await asyncio .sleep (1 )
2028
2129
22- async def main () -> None :
23- config = enapter .mqtt .Config (host = "127.0.0.1" , port = 1883 )
24- async with enapter .mqtt .Client (config = config ) as client :
25- async with asyncio .TaskGroup () as tg :
26- tg .create_task (subscriber (client ))
27- tg .create_task (publisher (client ))
28-
29-
3030if __name__ == "__main__" :
3131 asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments