caching.py 文件源码

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

项目:mumblecode 作者: mumbleskates 项目源码 文件源码
def __init__(self, session, cache, heuristic, transform=None, limiter=None, max_inflight=0):
        """
        :param session: requests session to use

        :param cache: cache to use

        :param heuristic: function that accepts a partially constructed Response object (with only
          `expiry` set to `None`) and returns the number of seconds this data will be fresh for.

        :param transform: function that accepts a partially constructed Response object (with `expiry` and
          `transformed` still set to `None`) and returns any object to represent this data, which may be used
          to determine the result's lifetime

        :param limiter: This object is called once every time the network is accessed. Any returned data is discarded.

        """
        self.session = session
        self.cache = cache
        self.heuristic = heuristic
        self.transform = transform or (lambda x: None)
        self.limiter = limiter or (lambda: None)
        if max_inflight > 0:
            self.inflight = Semaphore(max_inflight)
        else:
            self.inflight = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号