fix: 无限递归

This commit is contained in:
2024-09-14 16:36:19 +08:00
parent 615d96c663
commit bc0fffc079

View File

@@ -66,9 +66,13 @@ async def fetch(interval: ESInterval, size=1000) -> AsyncIterable[dict]:
# 这里使用递归
if len(docs) == size:
print("继续请求下一页数据")
start_time = parse_unixtime(docs[-1]["crawled_at"])
if start_time == interval.end_time:
print("已经到达时间段末尾,停止请求", start_time)
return
async for doc in fetch(
ESInterval(
start_time=parse_unixtime(docs[-1]["crawled_at"]),
start_time=start_time,
end_time=interval.end_time,
),
size,