_base.py 文件源码

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

项目:luckyhorse 作者: alexmbird 项目源码 文件源码
def get(self, p):
    '''
    Look for events fulfilling period `p` in cache and if possible, return them.
    Otherwise raise a RecordNotExist error.
    '''
    try:
      with self._lock:
        # This assumes that new events get straight into the cache
        if p.lhs_ts >= self._cache_latest_ts[0] and p.rhs_ts <= HORSEYTIEM.time():
          lhs_index  = self._cache_latest_ts.bisect_left(p.lhs_ts)
          rhs_index  = self._cache_latest_ts.bisect_left(p.rhs_ts)
          return tuple(islice(self._cache_latest_ev, lhs_index, rhs_index))
    except IndexError:
      pass

    raise RecordNotExistError()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号