hal 属性何时更新

发布于 2024-07-05 09:58:16 字数 258 浏览 11 评论 0原文

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

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-07-12 09:58:16

DeviceExists 方法怎么样(例如此处):

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

和PropertyModified信号,(来自现实世界的前身):

 #
 # _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 规范
D-Bus 规范
D-Bus 教程

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文