Fix: share client name

This commit is contained in:
TannedCung 2024-12-23 13:02:35 +07:00
parent d56aab4227
commit c3f5fde43e

View File

@ -20,6 +20,8 @@ from fwd_api.middleware.local_storage import get_current_trace_id
import csv import csv
import json import json
import copy import copy
import boto3
import datetime
from fwd_api.utils.accuracy import predict_result_to_ready from fwd_api.utils.accuracy import predict_result_to_ready
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
@ -33,6 +35,8 @@ s3_client = S3Util.MinioS3Client(
secret_key=settings.S3_SECRET_KEY, secret_key=settings.S3_SECRET_KEY,
bucket_name=settings.S3_BUCKET_NAME 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: def process_pdf_file(file_name: str, file_path: str, request, user, doc_type: str, index_in_request: int) -> list:
try: try:
@ -294,13 +298,8 @@ def upload_obj_to_s3(byte_obj, s3_key):
@app.task(base=VerboseTask, name='send_response_to_sqs') @app.task(base=VerboseTask, name='send_response_to_sqs')
def send_response_to_sqs(response_data, status_code): def send_response_to_sqs(response_data, status_code):
"""Send error responses to SQS for monitoring""" """Send error responses to SQS for monitoring"""
import boto3
import json
import datetime
try: try:
sqs_client = boto3.client('sqs', region_name=settings.AWS_REGION) # keys are stored in the cridental
message_body = { message_body = {
"status_code": status_code, "status_code": status_code,
"timestamp": int(datetime.datetime.now().timestamp()), "timestamp": int(datetime.datetime.now().timestamp()),