python subprocess never stops when called with -i argument
<p>I'm writing a python script that calls another python script (script2).  I want to get the print statements from script2 during the process, not only at the end.  I have this code:</p>

<pre><code>command = ['python', '-i', script2]
process = subprocess.Popen(command, 
                       stderr=subprocess.STDOUT, 
                       stdout = subprocess.PIPE)

print "process started"

while process.poll() is None:
    line = process.stdout.readline()
    if not line:
        break
    print line
</code></pre>

<p>This code does indeed print the output to the screen, but the subprocess never ends.
However, changing <code>command</code> to <code>command = ['python', script2]</code> ends the subprocess, but only prints the output to the screen AFTER the subprocess ended.  </p>

<p>How can I get the desired behaviour?  Thanks on beforehand,
Roel</p>
