tags:

views:

346

answers:

1

I'm calling GetProperty on a org.freedesktop.Hal.Device from my handler during a PropertyNotified signal. I'm only calling GetProperty on properties that have been added or changed.

When I call GetProperty during property adds, I'm getting a org.freedesktop.Hal.NoSuchProperty exception. I'm also worried that during changes, I'm getting the old values.

When should I be calling GetProperty? What race conditions are involved?

+1  A: 

How about DeviceExists method (like here):

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

And PropertyModified signal, (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

Max Gontar