From 638bf0dd1b419f2f3f9cc2028feacd5bf72eafc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Sun, 31 Aug 2025 01:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCelery=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在tasks/__init__.py中导入media_learning任务 - 在ops/__init__.py中注册media_learning任务到Celery应用 - 修复KeyError: 'media_learning_by_document'错误 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- apps/knowledge/tasks/__init__.py | 3 ++- apps/ops/__init__.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/knowledge/tasks/__init__.py b/apps/knowledge/tasks/__init__.py index 70835501..f9e603d9 100644 --- a/apps/knowledge/tasks/__init__.py +++ b/apps/knowledge/tasks/__init__.py @@ -2,4 +2,5 @@ # Import tasks for Celery discovery # Note: We import the specific tasks, not * to avoid circular imports -from .advanced_learning import advanced_learning_by_document, batch_advanced_learning \ No newline at end of file +from .advanced_learning import advanced_learning_by_document, batch_advanced_learning +from .media_learning import media_learning_by_document, media_learning_batch \ No newline at end of file diff --git a/apps/ops/__init__.py b/apps/ops/__init__.py index 579bec2c..df9e301b 100644 --- a/apps/ops/__init__.py +++ b/apps/ops/__init__.py @@ -19,3 +19,15 @@ try: celery_app.register_task(batch_advanced_learning) except ImportError: pass + +# Import and register media learning tasks +try: + from knowledge.tasks.media_learning import ( + media_learning_by_document, + media_learning_batch + ) + # Register tasks with the celery app + celery_app.register_task(media_learning_by_document) + celery_app.register_task(media_learning_batch) +except ImportError: + pass