Answers for "realtime output subprocess"

0

realtime output subprocess

import subprocess
import sys

process = subprocess.Popen(cmdCommand, shell = True,bufsize = 1,
                           stdout=subprocess.PIPE, stderr = subprocess.STDOUT,encoding='utf-8', errors = 'replace' ) 
while True:
    realtime_output = process.stdout.readline()
    if realtime_output == '' and process.poll() is not None:
        break
    if realtime_output:
        print(realtime_output.strip(), flush=False)
        sys.stdout.flush()
Posted by: Guest on July-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language