Explorar o código

fix(account): 防止多 router startup 重复启动 scheduler

alphah hai 1 semana
pai
achega
558448197b
Modificáronse 1 ficheiros con 7 adicións e 3 borrados
  1. 7 3
      backend/app/plugin/module_payment/account/controller.py

+ 7 - 3
backend/app/plugin/module_payment/account/controller.py

@@ -608,11 +608,15 @@ async def start_retry_scheduler():
         id='retry_dealing_transfers',
         replace_existing=True,
     )
-    scheduler.start()
+    if not scheduler.running:
+        scheduler.start()
+    else:
+        log.debug("[重试任务] 调度器已在运行,跳过启动")
     log.info("[重试任务] 定时任务已注册(每分钟执行)")
 
 
 @AccountRouter.on_event("shutdown")
 async def stop_retry_scheduler():
-    scheduler.shutdown(wait=False)
-    log.info("[重试任务] 定时任务已停止")
+    if scheduler.running:
+        scheduler.shutdown(wait=False)
+        log.info("[重试任务] 定时任务已停止")