From 1c5dfb12e1683f4a14fcd2610fc1d55c07607dd2 Mon Sep 17 00:00:00 2001 From: hiderfong Date: Sun, 26 Apr 2026 08:45:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(celery):=20=E4=BF=AE=E5=A4=8DAsyncResult?= =?UTF-8?q?=E7=BC=BA=E5=B0=91celery=5Fapp=E5=AF=BC=E8=87=B4DisabledBackend?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - project.py中AsyncResult调用添加app=celery_app参数 - 解决自动分类状态查询时500错误 --- backend/app/api/v1/project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/api/v1/project.py b/backend/app/api/v1/project.py index a20f804a..73e59547 100644 --- a/backend/app/api/v1/project.py +++ b/backend/app/api/v1/project.py @@ -115,7 +115,8 @@ def project_auto_classify( if background: # Check if already running if project.celery_task_id: - existing = AsyncResult(project.celery_task_id) + from app.tasks.worker import celery_app + existing = AsyncResult(project.celery_task_id, app=celery_app) if existing.state in ("PENDING", "PROGRESS", "STARTED"): return ResponseModel(data={"task_id": project.celery_task_id, "status": existing.state}) @@ -163,7 +164,8 @@ def project_auto_classify_status( progress = json.loads(project.scan_progress) if project.scan_progress else None return ResponseModel(data={"status": project.status, "progress": progress}) - result = AsyncResult(task_id) + from app.tasks.worker import celery_app + result = AsyncResult(task_id, app=celery_app) progress = None if result.state == "PROGRESS" and result.info: progress = result.info