Question: Asynchronous properties?
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
How to call an async method from a getter or setter?
An asynchronous method that returns a value. In this case, change the property to an async method. A value that can be used...
Read more >Async/Await - Best Practices in Asynchronous Programming
The problem is that the method reads the value and suspends itself at the await, and when the method resumes it assumes the...
Read more >How to create and use async properties - Hacking with Swift
How to create and use async properties ... Just as Swift's functions can be asynchronous, computed properties can also be asynchronous: attempting ...
Read more >Asynchronous JavaScript - Learn web development | MDN
In this article, we'll learn about synchronous and asynchronous programming, why we often need to use asynchronous techniques, and the problems ...
Read more >Solved For this assignment, you will need to understand - Chegg
Question : For this assignment, you will need to understand loops and the asynchronous properties of Node.js. Part 1: Looping Write a program...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let me know if that works.
Ok since the work is clear and I think it’s an important feature, I should get around to it soon.