From 4b5e59f35defe71183afcd3681f92f1689de30ad Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Thu, 19 Sep 2024 11:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=B7=BB=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cucyuqing/cmd/es-sync.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cucyuqing/cmd/es-sync.py b/cucyuqing/cmd/es-sync.py index 371d29e..9e65c30 100644 --- a/cucyuqing/cmd/es-sync.py +++ b/cucyuqing/cmd/es-sync.py @@ -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__":