paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

raise error when run the examples loop_asyncio.py

Open Jzhenli opened this issue 1 year ago • 1 comments

Hi, when run the examples loop_asyncio.py with paho-mqt 2.1.0 will raise NotImplementedError.

BTW, I test it on win11 with python3.10.

Jzhenli avatar Sep 06 '24 01:09 Jzhenli

Ran into the same issue. For me the error was due to asyncio defaulting to ProactorEventLoop, which on Windows does not support the loop.add_reader() and loop.add_writer() methods used in the loop_asyncio.py example. I was able to get the example working by putting the line

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

before the call to asyncio.get_event_loop() as suggested in this pyzmq issue.

arrisde avatar Oct 02 '25 08:10 arrisde