Skip to content

Commit 6556cd0

Browse files
committed
[lit] Simplify test scheduling via multiprocessing.Pool
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375458 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e672b94 commit 6556cd0

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

utils/lit/lit/run.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,20 @@ def console_ctrl_handler(type):
127127
return True
128128
lit.util.win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
129129

130-
try:
131-
async_results = [
132-
pool.apply_async(lit.worker.execute, args=[test],
133-
callback=lambda r, t=test: self._process_result(t, r))
134-
for test in self.tests]
135-
pool.close()
136-
137-
# Wait for all results to come in. The callback that runs in the
138-
# parent process will update the display.
139-
for a in async_results:
140-
timeout = deadline - time.time()
141-
a.wait(timeout)
142-
if not a.successful():
143-
# TODO(yln): this also raises on a --max-time time
144-
a.get() # Exceptions raised here come from the worker.
145-
if self.hit_max_failures:
146-
break
147-
except:
148-
# Stop the workers and wait for any straggling results to come in
149-
# if we exited without waiting on every async result.
150-
pool.terminate()
151-
raise
152-
finally:
153-
pool.join()
130+
async_results = [
131+
pool.apply_async(lit.worker.execute, args=[test],
132+
callback=lambda r, t=test: self._process_result(t, r))
133+
for test in self.tests]
134+
pool.close()
135+
136+
for ar in async_results:
137+
timeout = deadline - time.time()
138+
try:
139+
ar.get(timeout)
140+
except multiprocessing.TimeoutError:
141+
# TODO(yln): print timeout error
142+
pool.terminate()
143+
break
144+
if self.hit_max_failures:
145+
pool.terminate()
146+
break

0 commit comments

Comments
 (0)