PaddleNLP icon indicating copy to clipboard operation
PaddleNLP copied to clipboard

[Question]: uie 多进程?

Open yifeizhou980429 opened this issue 3 years ago • 1 comments

请提出你的问题

uie运行多进程报错问题,paddlenlp ==2.4.0 paddlepaddle == 2.3.2 python ==3.6.8 ,跑多进程(10个,100个) if "relations" not in relations[k][i].keys(): 这一行会报错keyerror,这是什么原因啊?

yifeizhou980429 avatar Oct 14 '22 09:10 yifeizhou980429

UIE使用多进程的是需要加锁的,

from flask import request, jsonify, Flask
from src.parser import DocParser
import threading
lock = threading.Lock()
server = Flask(__name__)

# 调用uie模型
parser = DocParser(model_path_prefix="src/uie/export/building/inference")


@server.route('/docParser', methods=['get', 'post'])
def parser_server():
    file = request.files.get('file')  # 接受上传文件
    lock.acquire()
    result = parser.parser_passage(file)
    if isinstance(result, dict):
        lock.release()
        return jsonify(result), 200
    else:
        lock.release()
        return jsonify({"msg": result}), 500


if __name__ == '__main__':
    server.run(port=9092, host='0.0.0.0', debug=False, threaded=True) 

wawltor avatar Oct 14 '22 11:10 wawltor

为什么要加锁?

datalee avatar Nov 30 '22 04:11 datalee

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] avatar Jan 30 '23 00:01 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。

github-actions[bot] avatar Feb 13 '23 00:02 github-actions[bot]