lockutils.py 文件源码

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

项目:LIS-Tempest 作者: LIS 项目源码 文件源码
def __enter__(self):
        self.lockfile = open(self.fname, 'w')

        while True:
            try:
                # Using non-blocking locks since green threads are not
                # patched to deal with blocking locking calls.
                # Also upon reading the MSDN docs for locking(), it seems
                # to have a laughable 10 attempts "blocking" mechanism.
                self.trylock()
                return self
            except IOError as e:
                if e.errno in (errno.EACCES, errno.EAGAIN):
                    # external locks synchronise things like iptables
                    # updates - give it some time to prevent busy spinning
                    time.sleep(0.01)
                else:
                    raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号