From 1b9df4d6dcc9466648e983c991b6e6a9267c15a2 Mon Sep 17 00:00:00 2001 From: pengxiaopeng Date: Wed, 6 Mar 2024 17:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=E5=86=99json=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debug/accuracy_tools/api_accuracy_checker/dump/info_dump.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/dump/info_dump.py b/debug/accuracy_tools/api_accuracy_checker/dump/info_dump.py index c71ac649c..e90b1f988 100644 --- a/debug/accuracy_tools/api_accuracy_checker/dump/info_dump.py +++ b/debug/accuracy_tools/api_accuracy_checker/dump/info_dump.py @@ -2,6 +2,7 @@ import fcntl import json import os import threading +import multiprocessing from api_accuracy_checker.dump.api_info import ForwardAPIInfo, BackwardAPIInfo from api_accuracy_checker.common.utils import check_file_or_directory_path, initialize_save_path, create_directory @@ -12,6 +13,7 @@ from api_accuracy_checker.common.config import msCheckerConfig from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen, FileCheckConst, FileChecker, change_mode lock = threading.Lock() +proc_lock = multiprocessing.Lock() def write_api_info_json(api_info): @@ -36,11 +38,12 @@ def write_api_info_json(api_info): def write_json(file_path, data, indent=None): check_file_or_directory_path(os.path.dirname(file_path), True) + proc_lock.acquire() + lock.acquire() if not os.path.exists(file_path): with FileOpen(file_path, 'w') as f: f.write("{\n}") change_mode(file_path, FileCheckConst.DATA_FILE_AUTHORITY) - lock.acquire() with FileOpen(file_path, 'a+') as f: fcntl.flock(f, fcntl.LOCK_EX) try: @@ -57,6 +60,7 @@ def write_json(file_path, data, indent=None): finally: fcntl.flock(f, fcntl.LOCK_UN) lock.release() + proc_lock.release() def initialize_output_json(): -- Gitee