问题描述
我正在编写一个python脚本,该脚本必须启动给出大量输出的子进程(此输出不得在我的工作环境中编写)。所以我先使用Subprocess.Popen
然后使用subprocess.stdout.readline()
。
不幸的是,经过几次测试和研究,我无法解决我的记忆问题。经过process.stdout.readline()的几次迭代后,我得到了超出范围错误的列表索引,但是由于我可以打印出``问题''值,所以我认为问题是内存问题。
我知道subprocess.Popen()
正在独立于主进程启动一个新的子进程,是否有办法为该子进程提供一定的内存? /减少使用的内存量?
我尝试直接在外壳中运行子进程,如果有帮助,它在大约8小时内消耗了803MB。
这是我的代码的一部分,返回了错误:
process = subprocess.Popen(["samtools mpileup -a -Q 0 -r " + REFERENCE + " -f " + REFERENCE + " " + BAM],stdout = subprocess.PIPE,shell=True,universal_newlines=True)
mpileup_line = process.stdout.readline().strip("\n").split("\t")
while ((int(mpileup_line[3])<COVERAGE) and (int(mpileup_line[1]) != int(gff_line[3]))):
if (i != int(gff_line[7])-1):
mpileup_line = process.stdout.readline().strip("\n").split("\t")
这是错误:
[mpileup] 1 samples in 1 input files
Traceback (most recent call last):
File "/work/cbirbes/axis1-assembly/errorCorrection_Pipeline/bin/Reductor.py",line 109,in <module>
while ((int(mpileup_line[3])<COVERAGE) and (int(mpileup_line[1]) != int(gff_line[3]))):
IndexError: list index out of range
正如我所说,在错误发生之前,我们可以同时打印int(mpileup_line[3]),COVERAGE,int(mpileup_line[1])
和int(gff_line[3])
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)