cache.py 文件源码

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

项目:Sentry 作者: NetEaseGame 项目源码 文件源码
def release(self):
        """
        Release the lock.
        """
        # If we went over the lock duration (timeout), we need to exit to avoid
        # accidentally releasing a lock that was acquired by another process.
        if not self.held:
            logger.warning('Tried to release unheld lock: %r', self)
            return False

        try:
            # XXX: There is a possible race condition here -- this could be
            # actually past the timeout due to clock skew or the delete
            # operation could reach the server after the timeout for a variety
            # of reasons. The only real fix for this would be to use a check
            # and delete operation, but that is backend dependent and not
            # supported by the cache API.
            self.cache.delete(self.lock_key)
        except Exception as e:
            logger.exception(e)
        finally:
            self.__acquired_at = None

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号