altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
191 stars 60 forks source link

Beware Of asyncio.get_event_loop() #101

Open ldo opened 2 years ago

ldo commented 2 years ago

Many of us have grown accustomed to writing

loop = asyncio.get_event_loop()

which, at least up to now, does one of 2 different things:

But note that, as of Python 3.10, assuming the first behaviour is deprecated. In future, this function will become a synonym for asyncio.get_running_loop(), which only has the second behaviour.

In fact, the whole idea of referring to a “current” event loop (as opposed to a “currently-running” event loop) is best avoided for the most part, and you will note that asyncio has been adding alternative functions you can use to comply with this. For example, asyncio.run() instead of loop.run_until_complete().

However, these alternative functions are only available as of Python 3.7 or later. So there will need to be some workarounds if you want to maintain compatibility with both pre-3.7 and the future.

acrisci commented 2 years ago

Thanks for letting me know. I'll do what it takes to maintain compatibility with future python changes once I am aware of specific issues.