why does python.subprocess hang after proc.communicate()?
Posted
by ccfenix
on Stack Overflow
See other posts from Stack Overflow
or by ccfenix
Published on 2010-03-09T11:35:21Z
Indexed on
2010/03/09
11:51 UTC
Read the original article
Hit count: 440
python
|subprocess
I've got an interactive program called my_own_exe
. First, it prints out alive
, then you input S\n
and then it prints out alive
again. Finally you input L\n
. It does some processing and exits.
However, when I call it from the following python script, the program seemed to hang after printing out the first 'alive'.
Can anyone here tell me why this is happening?
Thanks
proc2 = subprocess.Popen("my_own_exe", shell=True , stdin=subprocess.PIPE, stdout=subprocess.PIPE)
print proc2.communicate()[0]
time.sleep(2);
print "alive" # 'hang' after print this line
proc2.communicate('S\n')[0]
print "alive"
print proc2.communicate()[0]
time.sleep(6)
© Stack Overflow or respective owner