mirror of
https://git.rtems.org/rtems-tools/
synced 2025-05-14 23:39:46 +08:00
execute: Use the io python module for output capture.
This change drops the overhead of capturing the process output. The io module in Python is similar to the POSIX API for a file read where a read will return up to the buffer size rather than blocking until the buffer is full.
This commit is contained in:
parent
7d3350d0bb
commit
437092487f
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -37,6 +37,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -193,7 +194,11 @@ class execute(object):
|
|||||||
line = ''
|
line = ''
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
data = fh.read(1)
|
#
|
||||||
|
# The io module file handling return up to the size passed
|
||||||
|
# in.
|
||||||
|
#
|
||||||
|
data = fh.read(4096)
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
break
|
break
|
||||||
# str and bytes are the same type in Python2
|
# str and bytes are the same type in Python2
|
||||||
@ -255,7 +260,8 @@ class execute(object):
|
|||||||
stdout_thread = threading.Thread(target = _readthread,
|
stdout_thread = threading.Thread(target = _readthread,
|
||||||
name = '_stdout[%s]' % (name),
|
name = '_stdout[%s]' % (name),
|
||||||
args = (self,
|
args = (self,
|
||||||
proc.stdout,
|
io.open(proc.stdout.fileno(),
|
||||||
|
closefd = False),
|
||||||
self.output,
|
self.output,
|
||||||
''))
|
''))
|
||||||
stdout_thread.daemon = True
|
stdout_thread.daemon = True
|
||||||
@ -264,7 +270,8 @@ class execute(object):
|
|||||||
stderr_thread = threading.Thread(target = _readthread,
|
stderr_thread = threading.Thread(target = _readthread,
|
||||||
name = '_stderr[%s]' % (name),
|
name = '_stderr[%s]' % (name),
|
||||||
args = (self,
|
args = (self,
|
||||||
proc.stderr,
|
io.open(proc.stderr.fileno(),
|
||||||
|
closefd = False),
|
||||||
self.output,
|
self.output,
|
||||||
self.error_prefix))
|
self.error_prefix))
|
||||||
stderr_thread.daemon = True
|
stderr_thread.daemon = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user