design design batch
This commit is contained in:
@@ -12,7 +12,7 @@ from app.service.design_batch.utils.save_json import oss_upload_json
|
||||
from app.service.design_batch.utils.synthesis_item import update_base_size_priority, synthesis, synthesis_single
|
||||
|
||||
id_lock = threading.Lock()
|
||||
celery_app = Celery('tasks', broker='amqp://guest:guest@10.1.2.213:5672//', backend='rpc://')
|
||||
celery_app = Celery('tasks', broker=f'amqp://rabbit:123456@18.167.251.121:5672//', backend='rpc://', BROKER_CONNECTION_RETRY_ON_STARTUP=True)
|
||||
celery_app.conf.worker_log_format = '%(asctime)s %(filename)s [line:%(lineno)d] %(levelname)s %(message)s'
|
||||
celery_app.conf.worker_hijack_root_logger = False
|
||||
logging.getLogger('pika').setLevel(logging.WARNING)
|
||||
@@ -120,7 +120,7 @@ def batch_design(objects_data, tasks_id, json_name):
|
||||
|
||||
for t in threads:
|
||||
t.join()
|
||||
|
||||
logger.debug(object_response)
|
||||
oss_upload_json(minio_client, object_response, json_name)
|
||||
publish_status(tasks_id, "ok", json_name)
|
||||
return object_response
|
||||
|
||||
@@ -5,7 +5,7 @@ from app.service.design_batch.utils.MQ import publish_status
|
||||
|
||||
|
||||
async def start_design_batch_generate(data, file):
|
||||
generate_clothes_task = batch_design.delay(json.loads(file.decode())['objects'], data.total, data.tasks_id)
|
||||
generate_clothes_task = batch_design.delay(json.loads(file.decode())['objects'], data.tasks_id, data.file_name)
|
||||
print(generate_clothes_task)
|
||||
publish_status(data.tasks_id, "0/100", "")
|
||||
return {"task_id": data.tasks_id}
|
||||
|
||||
@@ -157,6 +157,6 @@ if __name__ == '__main__':
|
||||
],
|
||||
"process_id": "83"
|
||||
}
|
||||
task_id = 1
|
||||
task_id = 10086
|
||||
json_name = "test.json"
|
||||
batch_design.delay(data['objects'], task_id, json_name)
|
||||
|
||||
@@ -2,9 +2,11 @@ import json
|
||||
|
||||
import pika
|
||||
|
||||
from app.core.config import RABBITMQ_PARAMS
|
||||
|
||||
|
||||
def publish_status(task_id, progress, result):
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters('10.1.2.213'))
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(**RABBITMQ_PARAMS))
|
||||
channel = connection.channel()
|
||||
channel.queue_declare(queue='DesignBatch', durable=True)
|
||||
message = {'task_id': task_id, 'progress': progress, "result": result}
|
||||
|
||||
Reference in New Issue
Block a user