I have two small python files, the first reads a line with inputand then prints another line
a = input()
print('complete')
Second attempt to execute this as a subprocess
import subprocess
proc = subprocess.Popen('./simp.py',
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
bufsize=1)
print('writing')
proc.stdin.write(b'hey\n')
print('reading')
proc.stdout.readline()
The above script will print “write”, then “read”, but then freeze. At first I thought it was a stdout buffering problem, so I changed bufsize=1to bufsize=0, and this fixes the problem. However, it seems that stdin is causing the problem.
bufsize=1, proc.stdin.flush() , . , (1) (2) . write ? , bufsize stdin, stdout stderr , ?