if line is None or len(line) == 0:
time.sleep(0.1)
else:
yield line
if process.returncode != 0:
raise Exception("Error: Process finished with code {}".format(process.returncode))
After Change
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, env=env,
close_fds=ON_POSIX, text=True, bufsize=1)
// Make nonblocking output
stdout_queue = Queue()
stdout_reader = Thread(target=enqueue_output, args=(process.stdout, stdout_queue), daemon=True)
stdout_reader.start()
stderr_queue = Queue()
stderr_reader = Thread(target=enqueue_output, args=(process.stderr, stderr_queue), daemon=True)
stderr_reader.start()
while True:
try:
out = stdout_queue.get_nowait()
except Empty:
out = None
try: