diff options
author | Craig Tiller <ctiller@google.com> | 2017-09-12 13:15:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 13:15:03 -0700 |
commit | 0852acd8b3700b052676b21b096fc641fc4194aa (patch) | |
tree | 14cbc42e89de4239d2db12110f29ccb4d592cc83 /tools/run_tests/python_utils | |
parent | ed63aac1952b8f19c7f1b4186cae139613c77603 (diff) |
Revert "Let alarms trigger at end of jobset.py instead of clearing them"
Diffstat (limited to 'tools/run_tests/python_utils')
-rwxr-xr-x | tools/run_tests/python_utils/jobset.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index 6151a7276a..08d652ae3f 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -71,8 +71,10 @@ def platform_string(): if platform_string() == 'windows': pass else: + have_alarm = False def alarm_handler(unused_signum, unused_frame): - pass + global have_alarm + have_alarm = False signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None) signal.signal(signal.SIGALRM, alarm_handler) @@ -365,9 +367,10 @@ class Jobset(object): """Manages one run of jobs.""" def __init__(self, check_cancelled, maxjobs, newline_on_success, travis, - stop_on_failure, add_env, quiet_success, max_time): + stop_on_failure, add_env, quiet_success, max_time, clear_alarms): self._running = set() self._check_cancelled = check_cancelled + self._clear_alarms = clear_alarms self._cancelled = False self._failures = 0 self._completed = 0 @@ -452,7 +455,10 @@ class Jobset(object): if platform_string() == 'windows': time.sleep(0.1) else: - signal.alarm(10) + global have_alarm + if not have_alarm: + have_alarm = True + signal.alarm(10) signal.pause() def cancelled(self): @@ -468,7 +474,10 @@ class Jobset(object): while self._running: if self.cancelled(): pass # poll cancellation self.reap() - if platform_string() != 'windows': + # Clear the alarms when finished to avoid a race condition causing job + # failures. Don't do this when running multi-VM tests because clearing + # the alarms causes the test to stall + if platform_string() != 'windows' and self._clear_alarms: signal.alarm(0) return not self.cancelled() and self._failures == 0 @@ -498,7 +507,8 @@ def run(cmdlines, add_env={}, skip_jobs=False, quiet_success=False, - max_time=-1): + max_time=-1, + clear_alarms=True): if skip_jobs: resultset = {} skipped_job_result = JobResult() @@ -510,7 +520,7 @@ def run(cmdlines, js = Jobset(check_cancelled, maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS, newline_on_success, travis, stop_on_failure, add_env, - quiet_success, max_time) + quiet_success, max_time, clear_alarms) for cmdline, remaining in tag_remaining(cmdlines): if not js.start(cmdline): break |