1

我正在尝试锁定我的 GNOME 屏幕保护程序,但是 dbus.Lock方法正在等待响应。我希望它不要等待响应(只需发送信号以锁定屏幕保护程序,然后继续生活)。我该怎么做呢?(实际上,这段代码在一个线程中,所以我继续生活,但我仍然得到令人讨厌的错误)

session_bus = dbus.SessionBus()                                                                                                                                       
screensaver_proxy = session_bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
locked = screensaver_proxy.Lock(dbus_interface='org.gnome.ScreenSaver')
print "HELLO" # will never get called, due to:
/*
  locked = screensaver_proxy.Lock(dbus_interface='org.gnome.ScreenSaver')
  File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 68, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 140, in __call__
    **keywords)
  File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 620, in call_blocking
    message, timeout)
  DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken
*/
4

1 回答 1

4

呸。解决方案: http: //dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#making-asynchronous-method-calls

于 2010-12-10T11:07:42.590 回答