修复celery启动BUG稳定引入
This commit is contained in:
@@ -1,24 +1,9 @@
|
||||
"""Celery task module imports.
|
||||
"""Celery task package.
|
||||
|
||||
Celery autodiscover imports ``app.tasks``; importing task modules here ensures
|
||||
custom named tasks are registered when workers start.
|
||||
"""
|
||||
任务模块注册统一由 app.tasks.celery_app.CELERY_TASK_IMPORTS 控制。
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("video_gen")
|
||||
|
||||
try:
|
||||
from app.tasks import ( # noqa: F401
|
||||
generation_create_tasks,
|
||||
generation_poll_tasks,
|
||||
generation_download_tasks,
|
||||
generation_recovery_tasks,
|
||||
hot_opening_replicate_tasks,
|
||||
shot_replicate_tasks,
|
||||
shot_replicate_flow_tasks,
|
||||
module_async_recovery_tasks,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Celery 任务模块导入失败,worker 可能出现 unregistered task。")
|
||||
raise
|
||||
这里不要主动 import 子任务模块,避免以下问题:
|
||||
1. Celery worker 启动时循环导入;
|
||||
2. 新增任务文件后部分 worker 注册不完整;
|
||||
3. app.tasks.__init__ 被普通业务代码 import 时意外加载全部 Celery 任务。
|
||||
"""
|
||||
Reference in New Issue
Block a user