<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 11 November 2016 at 06:02, Jiajie Hu <span dir="ltr">&lt;<a href="mailto:jiajie.hu@intel.com" target="_blank">jiajie.hu@intel.com</a>&gt;</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(&#39;utf-8&#39;)(<wbr>process.stdout)<br>
     buf = &#39;&#39;<br>
     while True:<br>
-        out = process.stdout.read(1)<br>
-        out = out.decode(&#39;utf-8&#39;)<br>
+        out = reader.read(1, 1)</div></blockquote></div><br>A reader is definitely the right thing here, but I&#39;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&#39;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>