我有一个python脚本使用os.subprocess模块运行一些外部命令.但其中一个步骤需要很长时间,所以我想分开运行它.我需要启动它们,检查它们是否已完成,然后执行下一个不平行的命令.我的代码是这样的:
nproc = 24
for i in xrange(nproc):
#Run program in parallel
#Combine files generated by the parallel step
for i in xrange(nproc):
handle = open('Niben_%s_structures' % (zfile_name), 'w')
for i in xrange(nproc):
for zline in open('Niben_%s_file%d_structures' % (zfile_name,i)):handle.write(zline)
handle.close()
#Run next step
cmd = 'bowtie-build -f Niben_%s_precursors.fa bowtie-index/Niben_%s_precursors' % (zfile_name,zfile_name)
Run Code Online (Sandbox Code Playgroud) python ×1