(
build_files, data, variables, includes, depth, check, generator_input_info
)
| 604 | |
| 605 | |
| 606 | def LoadTargetBuildFilesParallel( |
| 607 | build_files, data, variables, includes, depth, check, generator_input_info |
| 608 | ): |
| 609 | parallel_state = ParallelState() |
| 610 | parallel_state.condition = threading.Condition() |
| 611 | # Make copies of the build_files argument that we can modify while working. |
| 612 | parallel_state.dependencies = list(build_files) |
| 613 | parallel_state.scheduled = set(build_files) |
| 614 | parallel_state.pending = 0 |
| 615 | parallel_state.data = data |
| 616 | |
| 617 | try: |
| 618 | parallel_state.condition.acquire() |
| 619 | while parallel_state.dependencies or parallel_state.pending: |
| 620 | if parallel_state.error: |
| 621 | break |
| 622 | if not parallel_state.dependencies: |
| 623 | parallel_state.condition.wait() |
| 624 | continue |
| 625 | |
| 626 | dependency = parallel_state.dependencies.pop() |
| 627 | |
| 628 | parallel_state.pending += 1 |
| 629 | global_flags = { |
| 630 | "path_sections": globals()["path_sections"], |
| 631 | "non_configuration_keys": globals()["non_configuration_keys"], |
| 632 | "multiple_toolsets": globals()["multiple_toolsets"], |
| 633 | } |
| 634 | |
| 635 | if not parallel_state.pool: |
| 636 | parallel_state.pool = multiprocessing.Pool(multiprocessing.cpu_count()) |
| 637 | parallel_state.pool.apply_async( |
| 638 | CallLoadTargetBuildFile, |
| 639 | args=( |
| 640 | global_flags, |
| 641 | dependency, |
| 642 | variables, |
| 643 | includes, |
| 644 | depth, |
| 645 | check, |
| 646 | generator_input_info, |
| 647 | ), |
| 648 | callback=parallel_state.LoadTargetBuildFileCallback, |
| 649 | ) |
| 650 | except KeyboardInterrupt as e: |
| 651 | parallel_state.pool.terminate() |
| 652 | raise e |
| 653 | |
| 654 | parallel_state.condition.release() |
| 655 | |
| 656 | parallel_state.pool.close() |
| 657 | parallel_state.pool.join() |
| 658 | parallel_state.pool = None |
| 659 | |
| 660 | if parallel_state.error: |
| 661 | sys.exit(1) |
| 662 | |
| 663 |
no test coverage detected
searching dependent graphs…