Files
kami_apple_exchage/backend/test_tasks.py
danial 8ad2a5366a refactor(backend): 将Celery替换为Arq进行协程任务处理
本次提交将后端的任务队列系统从Celery迁移到了Arq,以支持基于协程的任务处理。主要改动包括:
- 更新文档和配置文件,反映架构变化。
- 修改健康检查和服务初始化逻辑,以适应Arq的使用。
- 移除与Celery相关的代码,并添加Arq任务定义和调度器。
- 更新Dockerfile和相关脚本,确保Arq worker能够正确运行。
- 调整API和业务服务中的任务处理逻辑,移除对Celery的依赖。

这些改动旨在提高系统的异步处理能力和整体性能。
2025-09-18 16:02:05 +08:00

43 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
DEPRECATED: This test file for Celery has been replaced with Arq.
Please use app/tasks/crawler_tasks_arq.py for coroutine-based task processing.
"""
import sys
from pathlib import Path
# 添加项目根目录到Python路径
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def test_arq_task_registration():
"""测试Arq任务注册"""
try:
print("正在导入 Arq worker配置...")
from app.core.arq_worker import ArqWorkerSettings
settings = ArqWorkerSettings()
print(f"已注册的函数数量: {len(settings.functions)}")
print("已注册的函数:")
for func in settings.functions:
print(f"{func.__name__}")
print("\n✅ Arq worker配置成功!")
return True
except Exception as e:
print(f"❌ Arq任务配置测试失败: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
print("注意Celery已被Arq替代")
success = test_arq_task_registration()
sys.exit(0 if success else 1)