同步添加重试机制
This commit is contained in:
@@ -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__":
|
||||||
|
|||||||
Reference in New Issue
Block a user