diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-02-24 14:46:02 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-02-24 14:57:20 -0800 |
commit | 336ad50973779488314ce698af1cc6156351213d (patch) | |
tree | 048bdb380d6d313d1e2e66d0ee98304a96d1f23b /tools/run_tests | |
parent | a512c33e74486a56d9edb3b92594fd438e77e163 (diff) |
Use signals instead of sleep to wait for jobs
Diffstat (limited to 'tools/run_tests')
-rwxr-xr-x | tools/run_tests/jobset.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index df83b30516..39670f1898 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -33,6 +33,7 @@ import hashlib import multiprocessing import os import random +import signal import subprocess import sys import tempfile @@ -42,6 +43,12 @@ import time _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count() +# setup a signal handler so that signal.pause registers 'something' +# when a child finishes +# not using futures and threading to avoid a dependency on subprocess32 +signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None) + + def shuffle_iteratable(it): """Return an iterable that randomly walks it""" # take a random sampling from the passed in iterable @@ -232,7 +239,7 @@ class Jobset(object): if dead: return message('WAITING', '%d jobs running, %d complete, %d failed' % ( len(self._running), self._completed, self._failures)) - time.sleep(0.1) + signal.pause() def cancelled(self): """Poll for cancellation.""" |