gpt4 book ai didi

dbus - hal 属性何时更新

转载 作者:行者123 更新时间:2023-12-02 06:21:36 27 4
gpt4 key购买 nike

我在 PropertyNotified 信号期间从处理程序调用 org.freedesktop.Hal.Device 上的 GetProperty。我仅对已添加或更改的属性调用 GetProperty。

当我在添加属性期间调用 GetProperty 时,出现 org.freedesktop.Hal.NoSuchProperty 异常。我还担心在更改过程中,我会得到旧的值。

我应该什么时候调用 GetProperty?涉及哪些竞争条件?

最佳答案

DeviceExists 方法怎么样(如 here ):

    if device.PropertyExists('info.product'):
return device.GetProperty('info.product')
return "unknown"

PropertyModified信号,(ex from real world):

 #
# _CBHalDeviceConnected
#
# INTERNAL
#
# Callback triggered when a device is connected through Hal.
#

def _CBHalDeviceConnected(self, obj_path):
...
self.device.connect_to_signal("PropertyModified",
self._CBHalDeviceAuthStateChanged)
...

#
# _CBHalDeviceAuthStateChanged
#
# INTERNAL
#
# Callback triggered when a Hal device property is changed,
# for checking authorization state changes
#

def _CBHalDeviceAuthStateChanged(self,num_changes,properties):
for property in properties:
property_name, added, removed = property
if property_name == "pda.pocketpc.password":
self.logger.info("_CBHalDeviceAuthStateChanged:
device authorization state changed: reauthorizing")
self._ProcessAuth()

HAL 0.5.10 Specification
D-Bus Specification
D-Bus Tutorial

关于dbus - hal 属性何时更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69744/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com