Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
[lit] Simplify test scheduling via multiprocessing.Pool
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375458 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
yln committed Oct 21, 2019
1 parent 4050a70 commit 0406bf1
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions utils/lit/lit/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,20 @@ def console_ctrl_handler(type):
return True
lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)

try:
async_results = [
pool.apply_async(lit.worker.execute, args=[test],
callback=lambda r, t=test: self._process_result(t, r))
for test in self.tests]
pool.close()

# Wait for all results to come in. The callback that runs in the
# parent process will update the display.
for a in async_results:
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
except:
# Stop the workers and wait for any straggling results to come in
# if we exited without waiting on every async result.
pool.terminate()
raise
finally:
pool.join()
async_results = [
pool.apply_async(lit.worker.execute, args=[test],
callback=lambda r, t=test: self._process_result(t, r))
for test in self.tests]
pool.close()

for ar in async_results:
timeout = deadline - time.time()
try:
ar.get(timeout)
except multiprocessing.TimeoutError:
# TODO(yln): print timeout error
pool.terminate()
break
if self.hit_max_failures:
pool.terminate()
break

0 comments on commit 0406bf1

Please sign in to comment.