Yakifo/amqtt

asyncio.get_event_loop() deprecated in Python 3.10

FlyingDiver opened this issue · 3 comments

So the examples should probably be changed to use a supported method going forward. I'm not an asyncio expert, and all the variations I've tried using asyncio.get_running_loop() or asyncio.new_event_loop() have failed.

If anyone knows how this is supposed to work going forward, let me know and I'll test and update the docs.

tazle commented

I bumped into this when trying to update to 3.10, and got the following initialization working:

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    asyncio.ensure_future(watchdog(), loop=loop)
    asyncio.ensure_future(main(), loop=loop)
    loop.run_forever()

where async def main(): initializes MQTTClient, connects etc.

Where are you getting "loop" from?

tazle commented

Oops, sorry, missed one line from the copy-paste. Edited that into the original comment. It doesn't really help you very far, though, since there's the Event constructor issue detailed in #96.