daemon.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码
def wait_pyinotify(self, bld):

        class PE(w_pyinotify.ProcessEvent):
            def stop(self, event):
                self.notif.ev = True
                self.notif.stop()
                raise ValueError("stop for delete")

            process_IN_DELETE = stop
            process_IN_CLOSE = stop
            process_default = stop

        proc = PE()
        wm = w_pyinotify.WatchManager()
        notif = w_pyinotify.Notifier(wm, proc)
        proc.notif = notif

        # well, we should add all the folders to watch here
        for x in self.enumerate(bld.srcnode):
            wm.add_watch(x, w_pyinotify.IN_DELETE | w_pyinotify.IN_CLOSE_WRITE)

        try:
            # pyinotify uses an infinite loop ... not too nice, so we have to use an exception
            notif.loop()
        except ValueError:
            pass
        if not hasattr(notif, 'ev'):
            raise KeyboardInterrupt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号