28 lines
943 B
Python
28 lines
943 B
Python
|
|
from celery_app import app
|
||
|
|
from services.processing_service import processing_service
|
||
|
|
from utils.logger import get_logger
|
||
|
|
|
||
|
|
logger = get_logger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
@app.task(bind=True, max_retries=1, default_retry_delay=60)
|
||
|
|
def process_stp_task(self, task_id: str, file_path: str, stp_file_id: int,
|
||
|
|
process_params: dict):
|
||
|
|
"""Celery 任务:异步处理 STP 文件生成模具型腔"""
|
||
|
|
import asyncio
|
||
|
|
|
||
|
|
try:
|
||
|
|
logger.info(f"[celery] 开始处理: {task_id}")
|
||
|
|
asyncio.run(processing_service.process_file_with_storage(
|
||
|
|
task_id, file_path, stp_file_id, process_params
|
||
|
|
))
|
||
|
|
logger.info(f"[celery] 处理完成: {task_id}")
|
||
|
|
return {"task_id": task_id, "status": "completed"}
|
||
|
|
except Exception as exc:
|
||
|
|
logger.error(f"[celery] 处理失败: {task_id}, error={exc}")
|
||
|
|
try:
|
||
|
|
self.retry(exc=exc)
|
||
|
|
except Exception:
|
||
|
|
pass
|
||
|
|
raise
|