我需要一些控制子流程的帮助.
目前,我正在使用python控制软件的运行,如下面的代码所示.
import subprocess
# Declaring some input and output names for the third-party program
label = ['fname1', 'fname2', 'fname3', 'fname4']
input_list = [ 'inp.'+ l for l in label ]
output_list = [ 'out.'+ l for l in label ]
# Run all sets of input and output using the third-party software
for in, out in zip(input_list, output_list):
#The bash command to run the executable
command = f"mpirun pw.x < {in} > {out}"
subprocess.run(command, shell=True)
我的计算机有64个逻辑核,正如我用软件测试的那样,使用32和64不会改变计算速度,因此,我想编辑代码以适应两个并发子进程.跑mpirun -n 32 ...
码.
我不知道如何进行并发操作,比如排队和控制在给定时间允许运行多少子流程实例.
请问哪个模块/库可以帮助我完成这项工作?当然,非常感谢您提供一个代码示例.
另外,PBS/SLURM系统不是一个选项,因为我还在python脚本中做一些处理工作.
谢谢