I am currently launching the serials shell commands from python with subprocess and multiprocessing. here code is not real one, but similar :
def fakeFunc(cmd):
print("the pid "+str(os.getpid())+"begin", end=":")
process=Popen(cmd, stdout=PIPE, shell=True, stderr=STDOUT)
for line in iter(process.stdout.readline,b''):
line_str=line.decode(sys.stdout.encoding)
##### analyse line_str######
with Pool() as pool:
cmds=['mkdir -p /home/jeff/workspace/zebu/compile/vdv && cd /home/jeff/workspace/zebu/compile/vdv && compile', 'mkdir -p /home/jeff/workspace/zebu/compile/vdr && cd /home/jeff/workspace/zebu/compile/vdr && compile', 'mkdir -p /home/jeff/workspace/zebu/compile/rdv && cd /home/jeff/workspace/zebu/compile/rdv && compile']
pool.map_async(fakeFunc, cmds)
pool.close()
pool.join()
it seems that only the last one in cmds has been executed, other three ones jump out of function after the print("the pid "+str(os.getpid())+"begin", end=":"). any help is appreciated