pidfile.py 文件源码

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

项目:pscheduler 作者: perfsonar 项目源码 文件源码
def __enter__(self):
        if self.path is None:
            return self.pidfile

        self.pidfile = open(self.path, "a+")
        try:
            fcntl.flock(self.pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
        except IOError:
            self.pidfile = None
            raise SystemExit("Already running according to " + self.path)
        self.pidfile.seek(0)
        self.pidfile.truncate()
        self.pidfile.write(str(os.getpid()))
        self.pidfile.flush()
        self.pidfile.seek(0)
        return self.pidfile
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号