From 157a4d706bb2410b3c2460defdc7412400209a8f Mon Sep 17 00:00:00 2001 From: zy123 <646228430@qq.com> Date: Mon, 17 Feb 2025 16:40:10 +0800 Subject: [PATCH] =?UTF-8?q?2.17=20=E5=A2=9E=E5=8A=A0=E8=AF=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6pdf=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=951?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask_app/routes/test_preprocess.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/flask_app/routes/test_preprocess.py b/flask_app/routes/test_preprocess.py index 04c8990..f6a105f 100644 --- a/flask_app/routes/test_preprocess.py +++ b/flask_app/routes/test_preprocess.py @@ -1,3 +1,4 @@ +import multiprocessing import os from flask import request, jsonify, Blueprint, g @@ -30,12 +31,9 @@ def process_file(): # print(file_path) # 调用预处理函数 start_time = time.time() - result = preprocess_files( - output_folder=output_folder, - file_path=file_path, - file_type=file_type, - logger=logger - ) + with multiprocessing.Pool(processes=1) as pool: + # 调用 apply 或 apply_async 执行子进程任务 + result = pool.apply(preprocess_files, args=(output_folder, file_path, 2, logger,)) # 处理结果 if not result: