在PropertyNotified信号期间,我从我的处理程序调用org.freedesktop.Hal.Device上的GetProperty。我只在已添加或更改的属性上调用GetProperty。
当我在属性添加过程中调用GetProperty时,我得到了一个org.freedesktop.Hal.NoSuchProperty异常。我还担心,在改变的过程中,我会得到旧的价值观。
我应该在什么时候给GetProperty打电话?涉及哪些竞态条件?
发布于 2009-03-03 10:54:32
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
https://stackoverflow.com/questions/69744
复制相似问题