13
13
import argparse
14
14
import platform
15
15
import subprocess
16
- import multiprocessing as mp
16
+ from multiprocessing . pool import ThreadPool
17
17
from pathlib import Path
18
18
19
19
is_running_in_ci = (os .getenv ("CIRCLECI" ) is not None or
@@ -31,8 +31,8 @@ def run_command(where, command, all_output=False):
31
31
result = subprocess .run (command , shell = True , cwd = where , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
32
32
output = ""
33
33
if result .returncode or all_output :
34
- output += result .stdout .decode ("utf-8" ).strip (" \n " )
35
- output += result .stderr .decode ("utf-8" ).strip (" \n " )
34
+ output += result .stdout .decode ("utf-8" , errors = "ignore" ).strip (" \n " )
35
+ output += result .stderr .decode ("utf-8" , errors = "ignore" ).strip (" \n " )
36
36
return (result .returncode , output )
37
37
38
38
def generate (project ):
@@ -108,23 +108,22 @@ def compile_examples(paths, jobs, split, part):
108
108
chunk_size = math .ceil (len (projects ) / args .split )
109
109
projects = projects [chunk_size * args .part :min (chunk_size * (args .part + 1 ), len (projects ))]
110
110
111
- ctx = mp .get_context ("spawn" )
112
111
# first generate all projects
113
- with ctx . Pool (jobs ) as pool :
112
+ with ThreadPool (jobs ) as pool :
114
113
projects = pool .map (generate , projects )
115
114
results += projects .count (None )
116
115
117
116
# Filter projects for successful generation
118
117
projects = [p for p in projects if p is not None ]
119
118
# Then build the successfully generated ones
120
- with ctx . Pool (jobs ) as pool :
119
+ with ThreadPool (jobs ) as pool :
121
120
projects = pool .map (build , projects )
122
121
results += projects .count (None )
123
122
124
123
# Filter projects for successful compilation and runablity
125
124
projects = [p for p in projects if p is not None and "CI: run" in p .read_text ()]
126
125
# Then run the successfully compiled ones
127
- with ctx . Pool (jobs ) as pool :
126
+ with ThreadPool (jobs ) as pool :
128
127
projects = pool .map (run , projects )
129
128
results += projects .count (None )
130
129
0 commit comments