The most answer I met are stdout.readlines().
But some process never end, outputing log forever, so readlines() is blocked.
Of course, while xx.stdout.readline(): or while xx.stdout.read(1): or stdout.read() has the same problem.
For the read method is always blocked if there's no data in pipe(?file), is there a method like read(timeout=xxx) or read(max_len=xxx) or stdout.isAvalable etc, or can stdout be converted to a stream like object(which read method return -1 if no data available)
Example:
import subprocess
p = subprocess.Popen(['tail', '-f', 'test.log'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
time.sleep(10)
p.stdout.readlines() # blocked here, for `tail` watches the file forever and never exits