有子进程失败时停止所有子进程
This commit is contained in:
10
make.py
10
make.py
@@ -7,7 +7,7 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import dataclasses
|
||||
from multiprocessing import Process,Queue
|
||||
from multiprocessing import Process,Queue,Value
|
||||
from create_lambda_fun import search_lambda
|
||||
from create_signal_fun import moc_file_create
|
||||
|
||||
@@ -114,8 +114,10 @@ class cmd_item_t:
|
||||
cmd:str
|
||||
info:str
|
||||
|
||||
def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue):
|
||||
def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue,failed_num):
|
||||
while(not cmd_queue.empty()):
|
||||
if(failed_num.value>0):
|
||||
return
|
||||
try:
|
||||
cmd=cmd_queue.get_nowait()
|
||||
except Exception:
|
||||
@@ -125,6 +127,7 @@ def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue):
|
||||
ret=os.system(cmd.cmd)
|
||||
if(ret):
|
||||
return_list.put((cpu_index,False))
|
||||
failed_num.value+=1
|
||||
return
|
||||
return_list.put((cpu_index,True))
|
||||
|
||||
@@ -134,8 +137,9 @@ def run_cmd_queue(cmd_queue:Queue,cpu_num:int=4):
|
||||
return
|
||||
process_list = []
|
||||
return_list=Queue()
|
||||
failed_num=Value('i',0)
|
||||
for i in range(cpu_num):
|
||||
p = Process(target=run_cmd,args=(cmd_queue,i,return_list,))
|
||||
p = Process(target=run_cmd,args=(cmd_queue,i,return_list,failed_num,))
|
||||
p.start()
|
||||
process_list.append(p)
|
||||
for i in process_list:
|
||||
|
@@ -4,7 +4,7 @@ import sys
|
||||
import time
|
||||
import shutil
|
||||
import dataclasses
|
||||
from multiprocessing import Process,Queue
|
||||
from multiprocessing import Process,Queue,Value
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ OBJCPY="riscv64-unknown-elf-objcopy"
|
||||
OBJDUMP="riscv64-unknown-elf-objdump"
|
||||
|
||||
CFLAG=[
|
||||
"-march=rv32i",
|
||||
"-march=rv32i_zicsr",
|
||||
"-mabi=ilp32",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
@@ -95,7 +95,6 @@ def tran_path(path:str):
|
||||
|
||||
# 判断是否需要重新生成
|
||||
def check_rebuild(dst:str,src:list):
|
||||
# print(f"src:{src}")
|
||||
if(not os.path.exists(dst)):
|
||||
return True
|
||||
dst_time=os.path.getmtime(dst)
|
||||
@@ -105,9 +104,6 @@ def check_rebuild(dst:str,src:list):
|
||||
src_time.sort()
|
||||
if(src_time[-1]>dst_time):
|
||||
return True
|
||||
# for item in src_time:
|
||||
# if(item>dst_time):
|
||||
# return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -125,7 +121,6 @@ def read_depend_files(name:str):
|
||||
t+=line
|
||||
t=t.split(':')[-1].strip()
|
||||
t=t.split(' ')
|
||||
# print(f"依赖列表{t}")
|
||||
return t
|
||||
|
||||
|
||||
@@ -134,8 +129,10 @@ class cmd_item_t:
|
||||
cmd:str
|
||||
info:str
|
||||
|
||||
def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue):
|
||||
def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue,failed_num):
|
||||
while(not cmd_queue.empty()):
|
||||
if(failed_num.value>0):
|
||||
return
|
||||
try:
|
||||
cmd=cmd_queue.get_nowait()
|
||||
except Exception:
|
||||
@@ -145,6 +142,7 @@ def run_cmd(cmd_queue:Queue,cpu_index:int,return_list:Queue):
|
||||
ret=os.system(cmd.cmd)
|
||||
if(ret):
|
||||
return_list.put((cpu_index,False))
|
||||
failed_num.value+=1
|
||||
return
|
||||
return_list.put((cpu_index,True))
|
||||
|
||||
@@ -154,8 +152,9 @@ def run_cmd_queue(cmd_queue:Queue,cpu_num:int=4):
|
||||
return
|
||||
process_list = []
|
||||
return_list=Queue()
|
||||
failed_num=Value('i',0)
|
||||
for i in range(cpu_num):
|
||||
p = Process(target=run_cmd,args=(cmd_queue,i,return_list,))
|
||||
p = Process(target=run_cmd,args=(cmd_queue,i,return_list,failed_num,))
|
||||
p.start()
|
||||
process_list.append(p)
|
||||
for i in process_list:
|
||||
|
Reference in New Issue
Block a user