我在PropertyNotified信号期间从我的处理程序调用org.freedesktop.Hal.Device上的GetProperty。我只在已添加或更改的属性上调用GetProperty。
当我在属性添加期间调用GetProperty时,我得到一个org.freedesktop.Hal.NoSuchProperty异常。我也担心在变化期间,我会得到旧的价值观。
我什么时候应该拨打GetProperty?涉及哪些竞争条件?
答案 0 :(得分:1)
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()