We need to execute a system command using subprocess.Popen()
.
As the output has a large data, when we tried to use Popen.wait()
it got stuck.
pipe= subprocess.Popen(cmd, shell=False,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
pipe.wait()
So, we tried to put Popen.stdout
in a variable pstdout
. After which pstdout
got closed and we are unable to fetch the content in that file.
pipe.stdout.closed
pstdout.closed
Can anyone help how to avoid that hung or how to reopen pstdout
?
Quoting python documentation popen on function
Popen.wait()
:and maybe you are run into deadlock. use communicate instead.