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

Support coroutines as signal handlers (#2) #87

Closed ydirson closed 3 years ago

ydirson commented 3 years ago

This allows to pass a coroutine to on_<signal> in addition to the current support for non-async callables.

We could prefer instead to avoid if isinstance() and provide a separate API (eg. aio_on_<signal>) for each signal ? Not sure it's worth it.

Without such a support in dbus_next itself, some use cases can be expressed by using asyncio.create_task() calls inside the non-coro callback, but that its shows limits.