我正在使用pyxs
pythonxenstore客户机模块编写一个Upstart守护进程,它监视一个设备上GPIO控制器上的一组输出管脚。启动后,守护程序的基本结构是导出相关的pin,为pin添加相应的Xenstore路径,并为每个Xenstore路径添加和监视监视。监视部分是线程化的-对于每一个手表,都会创建一个线程,该线程使用一个目标worker方法来监视监视监视的更改。根据PyXS的文档,你基本上必须做一些事情,比如:
# monitor is a pyxs.client.Client.Monitor object, and watch adds a
# watch to the given path
monitor.watch(path, path_token)
# wait for events on the watched path - returns a pair if there is an
# event, the first is the event path and the second is the path token
monitor.wait(sleep=...)
我的问题是,如果没有指定sleep=<time>
参数,那么对wait
的调用是否会阻塞-从PyXS文档中不清楚是否是这样。在
代码大致如下:
^{pr2}$
来自^{} 文档:
这意味着,
sleep
参数实际上是分离对wait
方法的偶数检查,如果您查看github中的code:您将看到,
sleep
参数只是提供事件检查之间的抽头间隙,因为while True
循环一直在运行,直到您取消event
,或者如果您想:检查event
的速度有多快,sleep
则常规检查的速度越快。在因此,最后:
对
wait
方法的调用已经阻塞,sleep
只是为了给event
检查之间的时间间隔。在相关问题 更多 >
编程相关推荐