I have simple Python script to execute test suite both under Windows and Linux.
Every test writes its output to separate file.
I use subprocess.Popen class to execute shell command in a cycle.
Every shell command starts like that:
def system_execute(self, command, path, out_file):
params_list = command.split(' ')
file_path = os.path.join(path, out_file)
f = open(file_path, "w")
subprocess.Popen(params_list, stdout=f)
f.close()
It works fine, but script finishes its work before all output files have been written.
Actually, I getting hundreds of zero-size files, and it takes some time to finish writing output and close handles.
Could anyone explain the reason why it works so strange, and is there a synchronous way to do the same job?
Thanks
Before
f.close(), you have towait()for our subprocess.or just
(or, for easier file handling,