wallet.py 文件源码

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

项目:lbryum 作者: lbryio 项目源码 文件源码
def _write(self):
        if threading.currentThread().isDaemon():
            log.warning('daemon thread cannot write wallet')
            return
        if not self.modified:
            return
        s = json.dumps(self.data, indent=4, sort_keys=True)
        temp_path = "%s.tmp.%s" % (self.path, os.getpid())
        with open(temp_path, "w") as f:
            f.write(s)
            f.flush()
            os.fsync(f.fileno())

        if os.path.exists(self.path):
            mode = os.stat(self.path).st_mode
        else:
            mode = stat.S_IREAD | stat.S_IWRITE
        # perform atomic write on POSIX systems
        try:
            os.rename(temp_path, self.path)
        except:
            os.remove(self.path)
            os.rename(temp_path, self.path)
        os.chmod(self.path, mode)
        self.modified = False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号