<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 11 November 2016 at 06:02, Jiajie Hu <span dir="ltr"><<a href="mailto:jiajie.hu@intel.com" target="_blank">jiajie.hu@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":71x" class="a3s aXjCH m15852146079dbf74">+ reader = codecs.getreader('utf-8')(<wbr>process.stdout)<br>
buf = ''<br>
while True:<br>
- out = process.stdout.read(1)<br>
- out = out.decode('utf-8')<br>
+ out = reader.read(1, 1)</div></blockquote></div><br>A reader is definitely the right thing here, but I'm wondering why this needs to loop on single characters. As I understand it doing a read() on a reader wrapping stdout will read until it blocks (because the process hasn't got anything to output) so result in less pointless iterating.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Ross</div></div>