MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / execute

Function execute

utils/iwyu_tool.py:353–388  ·  view source on GitHub ↗

Launch processes described by invocations.

(invocations, verbose, formatter, jobs)

Source from the content-addressed store, hash-verified

351
352
353def execute(invocations, verbose, formatter, jobs):
354 """ Launch processes described by invocations. """
355 exit_code = 0
356 if jobs == 1:
357 for invocation in invocations:
358 proc = invocation.start(verbose)
359 print(formatter(proc.get_output()), end = "")
360 if proc.returncode != 2:
361 print("\n\033[91mfailure: \033[0m" + proc.source_file)
362 print(formatter(proc.get_output()), end = "")
363 exit_code = 1
364 else:
365 print("\033[92msuccess: \033[0m" + proc.source_file)
366 return exit_code
367
368 pending = []
369 while invocations or pending:
370 # Collect completed IWYU processes and print results.
371 complete = [proc for proc in pending if proc.poll() is not None]
372 for proc in complete:
373 pending.remove(proc)
374 if proc.returncode != 2:
375 print("\n\033[91mfailure: \033[0m" + proc.source_file)
376 print(formatter(proc.get_output()), end = "")
377 return 1
378 else:
379 print("\033[92msuccess: \033[0m" + proc.source_file)
380
381 # Schedule new processes if there's room.
382 capacity = jobs - len(pending)
383 pending.extend(i.start(verbose) for i in invocations[:capacity])
384 invocations = invocations[capacity:]
385
386 # Yield CPU.
387 time.sleep(0.0001)
388 return exit_code
389
390
391def main(compilation_db_path, source_files, verbose, formatter, jobs,

Callers 1

mainFunction · 0.85

Calls 3

get_outputMethod · 0.80
pollMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected