Python子进程readline()挂起
Main.py
from subprocess import Popen, PIPE, STDOUTimport ptyimport os file_path = '/Users/luciano/Desktop/ruby_sleep.rb'command = ' '. join(["ruby", file_path])master, slave = pty.openpty()proc = Popen(command, bufsize=0, shell=True, stdout=slave, stderr=slave, close_fds=True) stdout = os.fdopen(master, 'r', 0)while proc.poll() is None: data = stdout.readline() if data != "": print(data) else: breakprint("This is never reached!")
红宝石睡眠
puts "hello"sleep 2puts "goodbye!"
问题
编辑
胡子哥哥
相关分类