2008-09-16 7 views
4

PropertyNotified 신호 동안 내 처리기에서 org.freedesktop.Hal.Device에 대해 GetProperty를 호출합니다. 추가 또는 변경된 속성에 대해서만 GetProperty를 호출합니다.hal 속성이 업데이트 될 때

속성 추가 중에 GetProperty를 호출하면 org.freedesktop.Hal.NoSuchProperty 예외가 발생합니다. 나는 또한 변화하는 동안 나는 오래된 가치를 얻고 있다고 걱정한다.

언제 GetProperty를 호출해야합니까? 관련된 경쟁 조건은 무엇입니까?

답변

1

어떻게 에 대한 DeviceExists 방법 (같은 here) :

# 
# _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
:

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

그리고 신호 (ex from real world를) PropertyModified 10

관련 문제