弃用mq 采用回调接口方式
This commit is contained in:
@@ -13,8 +13,8 @@ logger = logging.getLogger(__name__)
|
||||
@shared_task(bind=True, queue="img_to_3d_queue", max_retries=3, name='src.server.canvas_generate_3D.tasks.img_to_3d_task')
|
||||
def img_to_3d_task(self, input_images: list, model: str = "single", callback_url: str = None):
|
||||
"""img_to_3D 主任务"""
|
||||
job_id = self.request.id
|
||||
logger.info(f"开始处理 img_to_3D 任务 | job_id: {job_id}")
|
||||
task_id = self.request.id
|
||||
logger.info(f"开始处理 img_to_3D 任务 | task_id: {task_id}")
|
||||
try:
|
||||
input_data = {
|
||||
"image_paths": input_images,
|
||||
@@ -27,13 +27,13 @@ def img_to_3d_task(self, input_images: list, model: str = "single", callback_url
|
||||
)
|
||||
status_code = resp.status_code
|
||||
result = resp.json()
|
||||
logger.info(f"img_to_3D 任务处理完成 | job_id: {job_id} | status_code : {status_code} | result: {result}")
|
||||
logger.info(f"img_to_3D 任务处理完成 | task_id: {task_id} | status_code : {status_code} | result: {result}")
|
||||
# 发送到对应的回调接口
|
||||
if status_code == 200:
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="completed",
|
||||
result=result,
|
||||
)
|
||||
@@ -42,7 +42,7 @@ def img_to_3d_task(self, input_images: list, model: str = "single", callback_url
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="failed",
|
||||
result={},
|
||||
)
|
||||
@@ -50,11 +50,11 @@ def img_to_3d_task(self, input_images: list, model: str = "single", callback_url
|
||||
return result
|
||||
|
||||
except Exception as exc:
|
||||
logger.error(f"img_to_3D 任务失败 | job_id: {job_id} | exc {exc}", exc_info=True)
|
||||
logger.error(f"img_to_3D 任务失败 | task_id: {task_id} | exc {exc}", exc_info=True)
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="failed",
|
||||
result=result,
|
||||
)
|
||||
@@ -65,8 +65,8 @@ def img_to_3d_task(self, input_images: list, model: str = "single", callback_url
|
||||
@shared_task(bind=True, queue="three_d_to_3views_queue", max_retries=3, name='src.server.canvas_generate_3D.tasks.three_d_to_3views_task')
|
||||
def three_d_to_3views_task(self, minio_glb_path: str, callback_url: str):
|
||||
"""3D to 3views 主任务"""
|
||||
job_id = self.request.id
|
||||
logger.info(f"开始处理 three_d_to_3views_task | job_id: {job_id}")
|
||||
task_id = self.request.id
|
||||
logger.info(f"开始处理 three_d_to_3views_task | task_id: {task_id}")
|
||||
try:
|
||||
input_data = {
|
||||
"minio_glb_path": minio_glb_path,
|
||||
@@ -78,13 +78,13 @@ def three_d_to_3views_task(self, minio_glb_path: str, callback_url: str):
|
||||
)
|
||||
status_code = resp.status_code
|
||||
result = resp.json()
|
||||
logger.info(f"three_d_to_3views_task 任务处理完成 | job_id: {job_id} | status_code : {status_code} | result: {result}")
|
||||
logger.info(f"three_d_to_3views_task 任务处理完成 | task_id: {task_id} | status_code : {status_code} | result: {result}")
|
||||
# 发送到对应的回调接口
|
||||
if status_code == 200:
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="completed",
|
||||
result=result,
|
||||
)
|
||||
@@ -93,7 +93,7 @@ def three_d_to_3views_task(self, minio_glb_path: str, callback_url: str):
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="failed",
|
||||
result={},
|
||||
)
|
||||
@@ -101,11 +101,11 @@ def three_d_to_3views_task(self, minio_glb_path: str, callback_url: str):
|
||||
return result
|
||||
|
||||
except Exception as exc:
|
||||
logger.error(f"three_d_to_3views_task 任务失败 | job_id: {job_id}", exc_info=True)
|
||||
logger.error(f"three_d_to_3views_task 任务失败 | task_id: {task_id}", exc_info=True)
|
||||
asyncio.run(
|
||||
notify_callback(
|
||||
callback_url=callback_url,
|
||||
job_id=job_id,
|
||||
task_id=task_id,
|
||||
status="failed",
|
||||
result={},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user