0
私は入力ストリームを実行するFORTRANプログラムを持っています。だから私は通常 "program.exe <入力>出力"コマンドを使用してプログラムを実行します。しかし、私は非同期にpythonでプログラムを実行したい。Pythonは入出力ストリームで外部プログラムを実行します
私が試した:
input = open("Input", 'rb').read()
running_procs = [Popen(['program.exe'], stdout=PIPE, stdin=PIPE, stderr=PIPE)]
while running_procs:
for proc in running_procs:
retcode = proc.poll()
if retcode is not None: # Process finished.
running_procs.remove(proc)
break
else: # No process is done, wait a bit and check again.
proc.stdin.write(input)
time.sleep(.1)
continue
# Here, `proc` has finished with return code `retcode`
if retcode != 0:
"""Error handling."""
print(proc.stdout)
を私は
proc.stdin.write(input)
これは、入力ストリームに書き込み入力を行います場合は知りません。
助けてください。