def _proc_async_iter_stream(proc, stream, buffersize=<NUM_LIT:1>):
from six.moves import queue<EOL>from threading import Thread<EOL>def enqueue_output(proc, stream, stream_queue):<EOL><INDENT>while proc.poll() is None:<EOL><INDENT>line = stream.readline()<EOL>stream_queue.put(line)<EOL><DEDENT>for line in _textio_iterlines(stream):<EOL><INDENT>stream_queue.put(line)<EOL><DEDENT>stream_queue.put(None)  <EOL><DEDENT>stream_queue = queue.Queue(maxsize=buffersize)<EOL>_thread = Thread(target=enqueue_output, args=(proc, stream, stream_queue))<EOL>_thread.daemon = True  <EOL>_thread.start()<EOL>return stream_queue<EOL>
Reads output from a process in a separate thread