@@ -35,26 +35,21 @@ def format_directories(directory_list):
3535 for filepaths_file in filepaths_files :
3636 filepaths_file .close ()
3737
38+ # Warm up pipx cache to avoid race conditions when spawning parallel processes
39+ subprocess .run (['pipx' , 'run' , f'clang-format=={ CLANG_FORMAT_VERSION } ' , '--version' ],
40+ check = True , capture_output = True )
41+
3842 processes = []
3943 for filepaths_file in filepaths_files :
4044 cmd = ['pipx' , 'run' , f'clang-format=={ CLANG_FORMAT_VERSION } ' ,
4145 f'--files={ filepaths_file .name } ' , '-i' , '-style=file:.clang-format' ]
42- p = subprocess .Popen (cmd , stderr = subprocess . PIPE )
43- processes .append (( p , cmd ) )
46+ p = subprocess .Popen (cmd )
47+ processes .append (p )
4448 print (f"Formatting generated files: { list2cmdline (cmd )} " )
4549
46- failed = False
47- for p , cmd in processes :
48- _ , stderr = p .communicate ()
49- if p .returncode != 0 :
50- print (f"ERROR: clang-format failed with exit code { p .returncode } : { list2cmdline (cmd )} " )
51- if stderr :
52- print (f" stderr: { stderr .decode ().strip ()} " )
53- failed = True
54-
55- if failed :
56- raise RuntimeError ("One or more clang-format processes failed" )
50+ for p in processes :
51+ p .wait ()
5752
5853 # Clean up temp file
5954 for filepaths_file in filepaths_files :
60- os .unlink (filepaths_file .name )
55+ os .unlink (filepaths_file .name )
0 commit comments