File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/python3
2
+ from concurrent .futures import ThreadPoolExecutor
3
+ import os
2
4
import re
3
5
import subprocess
4
6
import sys
@@ -25,7 +27,7 @@ def transform(s):
25
27
return "\n " .join ("//| " + line if line else "//|" for line in result ) + "\n "
26
28
27
29
28
- for fn in sys . argv [ 1 :] :
30
+ def process_one_file ( fn ) :
29
31
with open (fn , "r" , encoding = "utf-8" ) as f :
30
32
content = f .read ()
31
33
@@ -40,3 +42,11 @@ def transform(s):
40
42
41
43
with open (fn , "w" , encoding = "utf-8" ) as f :
42
44
f .write ("" .join (newcontent ))
45
+
46
+
47
+ if __name__ == "__main__" :
48
+ # Use a thread pool because most processing is inside black!
49
+ executor = ThreadPoolExecutor (max_workers = os .cpu_count ())
50
+ for fn in sys .argv [1 :]:
51
+ executor .submit (process_one_file , fn )
52
+ executor .shutdown ()
You can’t perform that action at this time.
0 commit comments