[PATCH v2 6/7] rtemstoolkit: Fixes to the reader and writer threads for capturing

chrisj at rtems.org chrisj at rtems.org
Mon Nov 26 00:56:24 UTC 2018


From: Chris Johns <chrisj at rtems.org>

- Use the 'read1' file handle call to return if any data is queued
  for reading from stdout or stderr.
- Flush the stdin pipe in the writer thread.

These changes let the execute module work on Python2 and Python3.
---
 rtemstoolkit/execute.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rtemstoolkit/execute.py b/rtemstoolkit/execute.py
index eb3c8c2..9fdc581 100755
--- a/rtemstoolkit/execute.py
+++ b/rtemstoolkit/execute.py
@@ -148,6 +148,7 @@ class execute(object):
                             if encoding:
                                 lines = bytes(lines, sys.stdin.encoding)
                             fh.write(lines)
+                            fh.flush()
                         except:
                             break
                     if lines == None or \
@@ -193,7 +194,7 @@ class execute(object):
                     # and the process is shutting down.
                     #
                     try:
-                        data = fh.read(4096)
+                        data = fh.read1(4096)
                     except:
                         data = ''
                     if len(data) == 0:
-- 
2.14.1




More information about the devel mailing list