파이썬 DBus에서 비동기 메서드를 구현하려면 어떻게해야합니까? 아래의 예 :파이썬 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.
저는 Twisted 's glib2 reactor를 사용하고 있습니다.
업데이트 :이 동작을 구현할 수 있음을 알고 있습니다. - DBus에는 메서드 호출에 대한 "직렬"(고유 식별자)이 포함되며 호출 된 메서드는 "호출"과 "응답"을 일치시키기 위해이 식별자에 액세스합니다. .
여기에서 수행하려는 작업이 모두 명확하지는 않습니다. 'getUsername'은 무엇을하기로되어 있습니까? –