aio-libs / aiozmq

Asyncio (pep 3156) integration with ZeroMQ
aiozmq.readthedocs.org
BSD 2-Clause "Simplified" License
422 stars 56 forks source link

Strange behaviour (or me not properly understanding asyncio and aiozmq) - Code only sends when publish more than once #188

Open marek-j opened 1 year ago

marek-j commented 1 year ago

The publish is only send (or received) when max > 1, but then it only sends one less time than asked to run.

 async def go():
     tb = await rpc.connect_pubsub(connect="tcp://localhost:5501")
     max = 2
     idx = 0
     while True:
        print("sleeping ")
        if idx < max:
            tb.publish("botupdates").message("Test")           
        await asyncio.sleep(4)
        idx = idx +1 

 asyncio.run(go())
marek-j commented 1 year ago

I go to the above example because this trivial example did not work:

 async def go():
     tb = await rpc.connect_pubsub(connect="tcp://localhost:5501")
     tb.publish("botupdates").message("Test")           
     while True:
        await asyncio.sleep(4)

 asyncio.run(go())