From c3f5fde43eb611863ba94f0d063ab4e6f35d38d1 Mon Sep 17 00:00:00 2001 From: TannedCung Date: Mon, 23 Dec 2024 13:02:35 +0700 Subject: [PATCH] Fix: share client name --- cope2n-api/fwd_api/celery_worker/internal_task.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cope2n-api/fwd_api/celery_worker/internal_task.py b/cope2n-api/fwd_api/celery_worker/internal_task.py index 84678fe..fc9491a 100755 --- a/cope2n-api/fwd_api/celery_worker/internal_task.py +++ b/cope2n-api/fwd_api/celery_worker/internal_task.py @@ -20,6 +20,8 @@ from fwd_api.middleware.local_storage import get_current_trace_id import csv import json import copy +import boto3 +import datetime from fwd_api.utils.accuracy import predict_result_to_ready from celery.utils.log import get_task_logger @@ -33,6 +35,8 @@ s3_client = S3Util.MinioS3Client( secret_key=settings.S3_SECRET_KEY, bucket_name=settings.S3_BUCKET_NAME ) +sqs_client = boto3.client('sqs'+ str(uuid.uuid4()), region_name=settings.AWS_REGION) # keys are stored in the cridental + def process_pdf_file(file_name: str, file_path: str, request, user, doc_type: str, index_in_request: int) -> list: try: @@ -294,13 +298,8 @@ def upload_obj_to_s3(byte_obj, s3_key): @app.task(base=VerboseTask, name='send_response_to_sqs') def send_response_to_sqs(response_data, status_code): """Send error responses to SQS for monitoring""" - import boto3 - import json - import datetime - try: - sqs_client = boto3.client('sqs', region_name=settings.AWS_REGION) # keys are stored in the cridental - + try: message_body = { "status_code": status_code, "timestamp": int(datetime.datetime.now().timestamp()),