I am going to use subprocess to handle commands in linux.
But I don't know when does this p1.stdout
will close. As This may influlence the data integrity which should be written to test
file.
p1 = subprocess.Popen('cat ', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, universal_newlines=True)
p2 = subprocess.Popen('cat ', stdin=p1.stdout, stdout=open("test", 'w'), shell=True, universal_newlines=True)
p1.stdin.write('asda'*100)
p1.stdin.close()
I know I can use p1.communicate()
after I write all data to p1.stdin
,But this function will close p1.stdout
too and I am certain if there is a chance that test
will lose a part of data.