aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests/python_utils
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-05-15 07:54:54 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-05-15 07:54:54 -0700
commit9d5d803bbf3e783cd12304d3aefa07eec6584f41 (patch)
treec7e4bff760409f4f019f64eccf56b71f8877fee0 /tools/run_tests/python_utils
parenta2d9d48a888bf9162d1288496e60920b481bf3eb (diff)
Small fixes
Diffstat (limited to 'tools/run_tests/python_utils')
-rwxr-xr-xtools/run_tests/python_utils/jobset.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py
index c1b1c88f55..27c6a6f622 100755
--- a/tools/run_tests/python_utils/jobset.py
+++ b/tools/run_tests/python_utils/jobset.py
@@ -225,6 +225,22 @@ class JobResult(object):
self.cpu_estimated = 1
self.cpu_measured = 0
+
+def eintr_be_gone(fn):
+ """Run fn until it doesn't stop because of EINTR"""
+ while True:
+ try:
+ return fn()
+ except IOError, e:
+ if e.errno != errno.EINTR:
+ raise
+
+
+def read_from_start(f):
+ f.seek(0)
+ return f.read()
+
+
class Job(object):
"""Manages one job."""
@@ -278,8 +294,7 @@ class Job(object):
def state(self):
"""Poll current state of the job. Prints messages at completion."""
def stdout(self=self):
- self._tempfile.seek(0)
- stdout = self._tempfile.read()
+ stdout = eintr_be_gone(lambda: read_from_start(self._tempfile))
self.result.message = stdout[-_MAX_RESULT_SIZE:]
return stdout
if self._state == _RUNNING and self._process.poll() is not None: