I am writing a large amount of data to stdin.
How do i ensure that it is not blocking?
p=subprocess.Popen([path],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
p.stdin.write('A very very very large amount of data')
p.stdin.flush()
output = p.stdout.readline()
It seems to hang at p.stdin.write()
after i read a large string and write to it.
I have a large corpus of files which will be written to stdin sequentially(>1k files)
So what happens is that i am running a loop
#this loop is repeated for all the files
for stri in lines:
p=subprocess.Popen([path],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
p.stdin.write(stri)
output = p.stdout.readline()
#do some processing
It somehow hangs at file no. 400. The file is a large file with long strings.
I do suspect its a blocking issue.
This only happens if i iterate from 0 to 1000. However, if i were to start from file 400, the error would not happen
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…