Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Commonmark migration
Source Link

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you do not require real-time output from the subprocess, use [Popen.communicate][1]Popen.communicate to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you do not require real-time output from the subprocess, use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you do not require real-time output from the subprocess, use Popen.communicate to avoid the polling loop.

Fixed grammer
Source Link
panickal
  • 1.2k
  • 9
  • 13

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you can afford wholedo not require real-time output from the subprocess, use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you can afford whole output from the subprocess, use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you do not require real-time output from the subprocess, use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

Add more info
Source Link
panickal
  • 1.2k
  • 9
  • 13

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you do not require real-timecan afford whole output from the subprocess, you could use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

Note: If you do not require real-time output from the subprocess, you could use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

From what I understand, you do not need to use pty. runner.py can be modified as

import subprocess
import sys
def main():
 process = subprocess.Popen(['python', 'outputter.py'],
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 while process.poll() is None:
 output = process.stdout.readline()
 sys.stdout.write(output)
 sys.stdout.flush()
 print "**ALL COMPLETED**"
if __name__ == '__main__':
 main()

process.stdout.read(1) can be used instead of process.stdout.readline() for real-time output per character from the subprocess.

Note: If you can afford whole output from the subprocess, use [Popen.communicate][1] to avoid the polling loop. [1]: http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate

Source Link
panickal
  • 1.2k
  • 9
  • 13
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /