From: Julian Lettner Date: Thu, 17 Oct 2019 16:01:18 +0000 (+0000) Subject: [lit] Synthesize artificial deadline X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=572aefc14783702a31cd165f01aa829b1dd8b2db;p=llvm [lit] Synthesize artificial deadline We always want to use a deadline when calling `result.await`. Let's synthesize an artificial deadline (positive infinity) to simplify code and do less busy waiting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375129 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/lit/lit/run.py b/utils/lit/lit/run.py index b73a7bc0a1f..fb53817dfc8 100644 --- a/utils/lit/lit/run.py +++ b/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,7 @@ 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 + deadline = (time.time() + self.max_time) if self.max_time else float('inf') semaphores = { k: NopSemaphore() if v is None else @@ -146,15 +143,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