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()
评论列表
文章目录