Skip to content
Snippets Groups Projects
Commit 82713635 authored by Craig Tiller's avatar Craig Tiller Committed by GitHub
Browse files

Merge pull request #11135 from ctiller/bugz

Fix some job runner bugs, save some initialization passes for port selection
parents 081c4424 f09957bd
No related branches found
No related tags found
No related merge requests found
...@@ -77,9 +77,11 @@ static int free_chosen_port(int port) { ...@@ -77,9 +77,11 @@ static int free_chosen_port(int port) {
static void free_chosen_ports(void) { static void free_chosen_ports(void) {
size_t i; size_t i;
grpc_init();
for (i = 0; i < num_chosen_ports; i++) { for (i = 0; i < num_chosen_ports; i++) {
grpc_free_port_using_server(chosen_ports[i]); grpc_free_port_using_server(chosen_ports[i]);
} }
grpc_shutdown();
gpr_free(chosen_ports); gpr_free(chosen_ports);
} }
......
...@@ -225,6 +225,22 @@ class JobResult(object): ...@@ -225,6 +225,22 @@ class JobResult(object):
self.cpu_estimated = 1 self.cpu_estimated = 1
self.cpu_measured = 0 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): class Job(object):
"""Manages one job.""" """Manages one job."""
...@@ -278,8 +294,7 @@ class Job(object): ...@@ -278,8 +294,7 @@ class Job(object):
def state(self): def state(self):
"""Poll current state of the job. Prints messages at completion.""" """Poll current state of the job. Prints messages at completion."""
def stdout(self=self): def stdout(self=self):
self._tempfile.seek(0) stdout = read_from_start(self._tempfile)
stdout = self._tempfile.read()
self.result.message = stdout[-_MAX_RESULT_SIZE:] self.result.message = stdout[-_MAX_RESULT_SIZE:]
return stdout return stdout
if self._state == _RUNNING and self._process.poll() is not None: if self._state == _RUNNING and self._process.poll() is not None:
...@@ -415,7 +430,7 @@ class Jobset(object): ...@@ -415,7 +430,7 @@ class Jobset(object):
while self._running: while self._running:
dead = set() dead = set()
for job in self._running: for job in self._running:
st = job.state() st = eintr_be_gone(lambda: job.state())
if st == _RUNNING: continue if st == _RUNNING: continue
if st == _FAILURE or st == _KILLED: if st == _FAILURE or st == _KILLED:
self._failures += 1 self._failures += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment