【问题标题】:call dbus method on proxy without blocking (or no timeout)在代理上调用 dbus 方法而不阻塞(或没有超时)
【发布时间】:2010-12-10 10:56:00
【问题描述】:

我正在尝试锁定我的 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
*/

【问题讨论】:

    标签: python dbus


    【解决方案1】:

    【讨论】:

    • 嗯。不幸的是,那里的文档并不广泛。在哪里提供reply_handlererror_handler 参数?显然不在get_object
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    • 2016-02-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多