From 9d5d803bbf3e783cd12304d3aefa07eec6584f41 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 15 May 2017 07:54:54 -0700 Subject: [PATCH] Small fixes --- test/core/util/port.c | 2 ++ tools/run_tests/python_utils/jobset.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/test/core/util/port.c b/test/core/util/port.c index da1ed4e052d..271ff226a7c 100644 --- a/test/core/util/port.c +++ b/test/core/util/port.c @@ -77,9 +77,11 @@ static int free_chosen_port(int port) { static void free_chosen_ports(void) { size_t i; + grpc_init(); for (i = 0; i < num_chosen_ports; i++) { grpc_free_port_using_server(chosen_ports[i]); } + grpc_shutdown(); gpr_free(chosen_ports); } diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index c1b1c88f550..27c6a6f6228 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: