summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-10-17 20:22:32 +0000
committerJulian Lettner <jlettner@apple.com>2019-10-17 20:22:32 +0000
commit2ca8e27bd038673b514c8452d661a413ce0d2123 (patch)
treecca1c57375f8d7d75aa525b7f38ea4fd6b459906
parent54017d0f526391a88e5e250a4bbc7a8ea77fa902 (diff)
downloadbcm5719-llvm-2ca8e27bd038673b514c8452d661a413ce0d2123.tar.gz
bcm5719-llvm-2ca8e27bd038673b514c8452d661a413ce0d2123.zip
Reland "[lit] Synthesize artificial deadline"
We always want to use a deadline when calling `result.await`. Let's synthesize an artificial deadline (now plus one year) to simplify code and do less busy waiting. Thanks to Reid Kleckner for diagnosing that a deadline for of "positive infinity" does not work with Python 3 anymore. See commit: 4ff1e34b606d9a9fcfd8b8b5449a558315af94e5 I tested this patch with Python 2 and Python 3. llvm-svn: 375165
-rw-r--r--llvm/utils/lit/lit/run.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/utils/lit/lit/run.py b/llvm/utils/lit/lit/run.py
index b73a7bc0a1f..7342661cc8f 100644
--- a/llvm/utils/lit/lit/run.py
+++ b/llvm/utils/lit/lit/run.py
@@ -12,6 +12,7 @@ class NopSemaphore(object):
def release(self): pass
def create_run(tests, lit_config, workers, progress_callback, max_time):
+ # TODO(yln) assert workers > 0
if workers == 1:
return SerialRun(tests, lit_config, progress_callback, max_time)
return ParallelRun(tests, lit_config, progress_callback, max_time, workers)
@@ -107,11 +108,9 @@ class ParallelRun(Run):
self.workers = workers
def _execute(self):
- # We need to issue many wait calls, so compute the final deadline and
- # subtract time.time() from that as we go along.
- deadline = None
- if self.max_time:
- deadline = time.time() + self.max_time
+ one_year = 365 * 24 * 60 * 60 # days * hours * minutes * seconds
+ max_time = self.max_time or one_year
+ deadline = time.time() + max_time
semaphores = {
k: NopSemaphore() if v is None else
@@ -146,15 +145,10 @@ class ParallelRun(Run):
# Wait for all results to come in. The callback that runs in the
# parent process will update the display.
for a in async_results:
- if deadline:
- a.wait(deadline - time.time())
- else:
- # Python condition variables cannot be interrupted unless
- # they have a timeout. This can make lit unresponsive to
- # KeyboardInterrupt, so do a busy wait with a timeout.
- while not a.ready():
- a.wait(1)
+ timeout = deadline - time.time()
+ a.wait(timeout)
if not a.successful():
+ # TODO(yln): this also raises on a --max-time time
a.get() # Exceptions raised here come from the worker.
if self.hit_max_failures:
break
OpenPOWER on IntegriCloud