同步添加重试机制

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

View File

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