Come implementare un metodo asincrono in Python DBus? Un esempio di seguito:Implementazione di un metodo asincrono in Python DBus
class LastfmApi(dbus.service.Object):
def __init__(self):
bus_name = dbus.service.BusName('fm.lastfm.api', bus=dbus.SessionBus())
dbus.service.Object.__init__(self, bus_name, '/')
@dbus.service.method('fm.last.api.account', out_signature="s")
def getUsername(self):
## How do I get this method done asynchronously ??
## For example, this method should go off and retrieve the "username"
## asynchronously. When this method returns, the "username" isn't available
## immediately but will be made available at a later time.
Sto usando reattore glib2 Twisted.
Aggiornamento: So che questo comportamento è possibile implementare - DBus include una (identificatore unico) "di serie" per chiamate di metodo e il metodo chiamato ha accesso a questo identificatore al fine di corrispondere "chiamate" con "risposte" .
Non è del tutto chiaro cosa vuoi ottenere qui. Cosa dovrebbe fare 'getUsername'? –