I want to wed python-dbus-next with mopidy-async-client. Since mopidy-async-client is asynchronous, I have a couple of async methods in my interface. That works fine.
When the service comes available, the sound applet is checking for its capabilities, e.g. it requests SupportedUriSchemes, which I implemented in the dbus-next interface. The problem I have, is that some of these property getters (and some setters) also use asynchronous functions of the mopdiy-async-client, e.g.:
class MopidyInterface(dbus_next.service.ServiceInterface):
def __init__(self, mopidy):
super().__init__('org.mpris.MediaPlayer2.Player')
self.mopidy = mopidy
@dbus_property(access=PropertyAccess.READ)
def SupportedUriSchemes(self) -> 's':
schemes = self.mopidy.core.get_uri_schemes()
return schemes
where .get_uri_schemes() is an asynchronous method. So this does not work, because it would require an await. The error message is:
/usr/local/lib/python3.8/dist-packages/dbus_next/message_bus.py:230: RuntimeWarning: coroutine 'CoreController.get_uri_schemes' was never awaited
body[interface.name][prop.name] = Variant(prop.signature,
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
If I change it naïvely to
@dbus_property(access=PropertyAccess.READ)
async def PlaybackStatus(self) -> 's':
state = await self.mopidy.playback.get_status()
return state.capitalize()
I get the very same error.
Is there a way to have asynchronous properties?
I want to wed
python-dbus-nextwithmopidy-async-client. Sincemopidy-async-clientis asynchronous, I have a couple ofasyncmethods in my interface. That works fine.When the service comes available, the sound applet is checking for its capabilities, e.g. it requests
SupportedUriSchemes, which I implemented in thedbus-nextinterface. The problem I have, is that some of these property getters (and some setters) also use asynchronous functions of themopdiy-async-client, e.g.:where
.get_uri_schemes()is an asynchronous method. So this does not work, because it would require anawait. The error message is:If I change it naïvely to
I get the very same error.
Is there a way to have asynchronous properties?