It is a block buffering issueblock buffering issue: when stdout is redirected to a pipe parent.py accumulates its output in an internal buffer (~4K-8K) i.e., you won't see anything for around an hour until the buffer overflows.
To disable buffering, pass -u command-line option:
#!/usr/bin/env python import os import sys from subprocess import Popen, PIPE, STDOUT script_path = os.path.join(get_script_dir(), 'parent.py') p = Popen([sys.executable, '-u', script_path], stdout=PIPE, stderr=STDOUT, bufsize=1) with p.stdout: for line in iter(p.stdout.readline, b''): print line, p.wait() See:
- Python: read streaming input from subprocess.communicate()Python: read streaming input from subprocess.communicate()
- Call python script with input with in a python script using subprocessCall python script with input with in a python script using subprocess
Note: if you don't need to do anything with the output then just drop stdout=PIPE, to see the output in the console:
subprocess.check_call([sys.executable, script_path])