From fc6d8ee77f00fb38d4dcba560a4af9507c2ae22e Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Fri, 30 Aug 2024 18:41:31 +0800 Subject: [PATCH] ignore when save image fail (#2178) ### What problem does this PR solve? ### Type of change - [x] Performance Improvement --- rag/svr/task_executor.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index 1dd0482da..3a9eb7390 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -206,15 +206,20 @@ def build(row): docs.append(d) continue - output_buffer = BytesIO() - if isinstance(d["image"], bytes): - output_buffer = BytesIO(d["image"]) - else: - d["image"].save(output_buffer, format='JPEG') + try: + output_buffer = BytesIO() + if isinstance(d["image"], bytes): + output_buffer = BytesIO(d["image"]) + else: + d["image"].save(output_buffer, format='JPEG') + + st = timer() + MINIO.put(row["kb_id"], d["_id"], output_buffer.getvalue()) + el += timer() - st + except Exception as e: + cron_logger.error(str(e)) + traceback.print_exc() - st = timer() - MINIO.put(row["kb_id"], d["_id"], output_buffer.getvalue()) - el += timer() - st d["img_id"] = "{}-{}".format(row["kb_id"], d["_id"]) del d["image"] docs.append(d)