Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 919d78c

Browse files
committed
Always use the multiprocess module.
This seems to work on freebsd and openbsd these days. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303280 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent aabc860 commit 919d78c

File tree

2 files changed

+3
-115
lines changed

2 files changed

+3
-115
lines changed

utils/lit/lit/main.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,6 @@ def main_with_tmp(builtinParameters):
282282
debug_group.add_argument("--show-tests", dest="showTests",
283283
help="Show all discovered tests",
284284
action="store_true", default=False)
285-
debug_group.add_argument("--use-process-pool", dest="executionStrategy",
286-
help="Run tests in parallel with a process pool",
287-
action="store_const", const="PROCESS_POOL")
288-
debug_group.add_argument("--use-processes", dest="executionStrategy",
289-
help="Run tests in parallel with processes (not threads)",
290-
action="store_const", const="PROCESSES")
291-
debug_group.add_argument("--use-threads", dest="executionStrategy",
292-
help="Run tests in parallel with threads (not processes)",
293-
action="store_const", const="THREADS")
294285

295286
opts = parser.parse_args()
296287
args = opts.test_paths
@@ -305,9 +296,6 @@ def main_with_tmp(builtinParameters):
305296
if opts.numThreads is None:
306297
opts.numThreads = lit.util.detectCPUs()
307298

308-
if opts.executionStrategy is None:
309-
opts.executionStrategy = 'PROCESS_POOL'
310-
311299
if opts.maxFailures == 0:
312300
parser.error("Setting --max-failures to 0 does not have any effect.")
313301

@@ -490,8 +478,7 @@ def main_with_tmp(builtinParameters):
490478
startTime = time.time()
491479
display = TestingProgressDisplay(opts, len(run.tests), progressBar)
492480
try:
493-
run.execute_tests(display, opts.numThreads, opts.maxTime,
494-
opts.executionStrategy)
481+
run.execute_tests(display, opts.numThreads, opts.maxTime)
495482
except KeyboardInterrupt:
496483
sys.exit(2)
497484
display.finish()

utils/lit/lit/run.py

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
except ImportError:
1414
win32api = None
1515

16-
try:
17-
import multiprocessing
18-
except ImportError:
19-
multiprocessing = None
20-
16+
import multiprocessing
2117
import lit.Test
2218

2319
def abort_now():
@@ -227,8 +223,7 @@ def __init__(self, lit_config, tests):
227223
def execute_test(self, test):
228224
return execute_test(test, self.lit_config, self.parallelism_semaphores)
229225

230-
def execute_tests(self, display, jobs, max_time=None,
231-
execution_strategy=None):
226+
def execute_tests(self, display, jobs, max_time=None):
232227
"""
233228
execute_tests(display, jobs, [max_time])
234229
@@ -249,100 +244,6 @@ def execute_tests(self, display, jobs, max_time=None,
249244
computed. Tests which were not actually executed (for any reason) will
250245
be given an UNRESOLVED result.
251246
"""
252-
253-
if execution_strategy == 'PROCESS_POOL':
254-
self.execute_tests_with_mp_pool(display, jobs, max_time)
255-
return
256-
# FIXME: Standardize on the PROCESS_POOL execution strategy and remove
257-
# the other two strategies.
258-
259-
use_processes = execution_strategy == 'PROCESSES'
260-
261-
# Choose the appropriate parallel execution implementation.
262-
consumer = None
263-
if jobs != 1 and use_processes and multiprocessing:
264-
try:
265-
task_impl = multiprocessing.Process
266-
queue_impl = multiprocessing.Queue
267-
sem_impl = multiprocessing.Semaphore
268-
canceled_flag = multiprocessing.Value('i', 0)
269-
consumer = MultiprocessResultsConsumer(self, display, jobs)
270-
except:
271-
# multiprocessing fails to initialize with certain OpenBSD and
272-
# FreeBSD Python versions: http://bugs.python.org/issue3770
273-
# Unfortunately the error raised also varies by platform.
274-
self.lit_config.note('failed to initialize multiprocessing')
275-
consumer = None
276-
if not consumer:
277-
task_impl = threading.Thread
278-
queue_impl = queue.Queue
279-
sem_impl = threading.Semaphore
280-
canceled_flag = LockedValue(0)
281-
consumer = ThreadResultsConsumer(display)
282-
283-
self.parallelism_semaphores = {k: sem_impl(v)
284-
for k, v in self.lit_config.parallelism_groups.items()}
285-
286-
# Create the test provider.
287-
provider = TestProvider(queue_impl, canceled_flag)
288-
handleFailures(provider, consumer, self.lit_config.maxFailures)
289-
290-
# Putting tasks into the threading or multiprocessing Queue may block,
291-
# so do it in a separate thread.
292-
# https://docs.python.org/2/library/multiprocessing.html
293-
# e.g: On Mac OS X, we will hang if we put 2^15 elements in the queue
294-
# without taking any out.
295-
queuer = task_impl(target=provider.queue_tests, args=(self.tests, jobs))
296-
queuer.start()
297-
298-
# Install a console-control signal handler on Windows.
299-
if win32api is not None:
300-
def console_ctrl_handler(type):
301-
provider.cancel()
302-
return True
303-
win32api.SetConsoleCtrlHandler(console_ctrl_handler, True)
304-
305-
# Install a timeout handler, if requested.
306-
if max_time is not None:
307-
def timeout_handler():
308-
provider.cancel()
309-
timeout_timer = threading.Timer(max_time, timeout_handler)
310-
timeout_timer.start()
311-
312-
# If not using multiple tasks, just run the tests directly.
313-
if jobs == 1:
314-
run_one_tester(self, provider, consumer)
315-
else:
316-
# Otherwise, execute the tests in parallel
317-
self._execute_tests_in_parallel(task_impl, provider, consumer, jobs)
318-
319-
queuer.join()
320-
321-
# Cancel the timeout handler.
322-
if max_time is not None:
323-
timeout_timer.cancel()
324-
325-
# Update results for any tests which weren't run.
326-
for test in self.tests:
327-
if test.result is None:
328-
test.setResult(lit.Test.Result(lit.Test.UNRESOLVED, '', 0.0))
329-
330-
def _execute_tests_in_parallel(self, task_impl, provider, consumer, jobs):
331-
# Start all of the tasks.
332-
tasks = [task_impl(target=run_one_tester,
333-
args=(self, provider, consumer))
334-
for i in range(jobs)]
335-
for t in tasks:
336-
t.start()
337-
338-
# Allow the consumer to handle results, if necessary.
339-
consumer.handle_results()
340-
341-
# Wait for all the tasks to complete.
342-
for t in tasks:
343-
t.join()
344-
345-
def execute_tests_with_mp_pool(self, display, jobs, max_time=None):
346247
# Don't do anything if we aren't going to run any tests.
347248
if not self.tests or jobs == 0:
348249
return

0 commit comments

Comments
 (0)