Python:限制进程调用的数量系统操作系统

2024-07-08 11:51:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要并行运行程序,一次3个。我尝试了下面的方法,但是当programC在A和B之前完成时,它不起作用。我怎样才能限制正在运行的程序的数量,比如说,在任何时候最多3个。在

for i in range(10):
     os.system("xterm -e program " + i + "a" + " &")
     os.system("xterm -e program " + i + "b" + " &") 
     os.system("xterm -e program " + i + "c" + " ")

Tags: 方法in程序for数量osrangeprogram

热门问题