Skip to content

Commit 54418a4

Browse files
committed
Parallelize processing of HTML files.
Processing the HTML files (renaming, cleaning, XSL transform) is now done in parallel, which cuts down the build time by a huge amount.
1 parent e2603ee commit 54418a4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

preprocess.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import shutil
2525
import urllib.parse
2626
from xml_utils import xml_escape, xml_unescape
27+
from multiprocessing import Pool
2728

2829
# copy the source tree
2930
os.system('rm -rf output/reference')
@@ -157,7 +158,8 @@ def rlink_fix(match):
157158
return pre + target + post
158159

159160
# clean the html files
160-
for fn in html_files:
161+
162+
def clean_file(fn):
161163
f = open(fn, "r")
162164
text = f.read()
163165
f.close()
@@ -173,8 +175,11 @@ def rlink_fix(match):
173175
ret = os.system('xsltproc --novalid --html --encoding UTF-8 preprocess.xsl "' + fn + '" > "' + tmpfile + '"')
174176
if ret != 0:
175177
print("FAIL: " + fn)
176-
continue
177-
os.system('mv "' + tmpfile + '" "' + fn + '"')
178+
else:
179+
os.system('mv "' + tmpfile + '" "' + fn + '"')
180+
181+
with Pool() as pool:
182+
pool.map(clean_file, html_files)
178183

179184
# append css modifications
180185

0 commit comments

Comments
 (0)