同步添加重试机制

This commit is contained in:
2024-09-19 11:07:16 +08:00
parent 7395d98ce3
commit 4b5e59f35d

View File

@@ -2,6 +2,7 @@
ES 数据同步脚本 ES 数据同步脚本
""" """
import traceback
import asyncio import asyncio
import time import time
import json import json
@@ -219,9 +220,15 @@ async def sync():
async def main(): async def main():
while True: while True:
await sync() try:
print("同步完成,等待下一轮同步") await sync()
await asyncio.sleep(60) print("同步完成,等待下一轮同步")
except Exception as e:
# 打印出错误堆栈
traceback.print_exc()
print("同步出错,等待 60 秒后重试", e)
finally:
await asyncio.sleep(60)
if __name__ == "__main__": if __name__ == "__main__":