mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-23 13:09:12 +08:00
rtemstoolkit: Fixes to the reader and writer threads for capturing
- 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.
This commit is contained in:
@@ -148,6 +148,7 @@ class execute(object):
|
|||||||
if encoding:
|
if encoding:
|
||||||
lines = bytes(lines, sys.stdin.encoding)
|
lines = bytes(lines, sys.stdin.encoding)
|
||||||
fh.write(lines)
|
fh.write(lines)
|
||||||
|
fh.flush()
|
||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
if lines == None or \
|
if lines == None or \
|
||||||
@@ -193,12 +194,12 @@ class execute(object):
|
|||||||
# and the process is shutting down.
|
# and the process is shutting down.
|
||||||
#
|
#
|
||||||
try:
|
try:
|
||||||
data = fh.read(4096)
|
data = fh.read1(4096)
|
||||||
except:
|
except:
|
||||||
data = ''
|
data = ''
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
_output_line(l + '\n', exe, prefix, out, count)
|
_output_line(line + '\n', exe, prefix, out, count)
|
||||||
break
|
break
|
||||||
# str and bytes are the same type in Python2
|
# str and bytes are the same type in Python2
|
||||||
if type(data) is not str and type(data) is bytes:
|
if type(data) is not str and type(data) is bytes:
|
||||||
|
Reference in New Issue
Block a user