diff --git a/video-gen-api/app/config.py b/video-gen-api/app/config.py index cf044acf..7f4621f8 100644 --- a/video-gen-api/app/config.py +++ b/video-gen-api/app/config.py @@ -112,6 +112,8 @@ class Settings(BaseSettings): # ChatAPI async generation pipeline settings CELERY_BROKER_URL: str = "" CELERY_RESULT_BACKEND: str = "" + # Celery result backend 仅保留近期排障状态;业务恢复以数据库状态和业务日志为准。 + CELERY_RESULT_EXPIRES_SECONDS: int = 7200 # Celery async 兼容配置。 # single_loop:每个 Celery 子进程一个专用 event loop,推荐线上/本地统一使用。 # direct:旧版线程本地 loop 降级模式,建议配合 CELERY_DB_USE_NULLPOOL=true。 diff --git a/video-gen-api/app/tasks/celery_app.py b/video-gen-api/app/tasks/celery_app.py index 58e2435f..43f210a7 100644 --- a/video-gen-api/app/tasks/celery_app.py +++ b/video-gen-api/app/tasks/celery_app.py @@ -77,6 +77,8 @@ if broker_url: task_serializer="json", accept_content=["json"], result_serializer="json", + result_expires=max(60, int(settings.CELERY_RESULT_EXPIRES_SECONDS or 7200)), + task_store_errors_even_if_ignored=True, timezone="Asia/Shanghai", enable_utc=True, task_soft_time_limit=600,