recipe-577911.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def __enter__(self):
        self.pidfile = open(self.path, "a+")
        try:
            fcntl.flock(self.pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
        except IOError:
            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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号