Commit 5dfa9d45 authored by Sebastian Friedl's avatar Sebastian Friedl
Browse files

Improve multiprocess handling in build script

parent 7ec08797
......@@ -3,7 +3,6 @@
from multiprocessing import Pool
import os
from pathlib import Path
import sys
from time import time
from fontTools.ttLib import TTFont
......@@ -203,15 +202,15 @@ def generate_stylesheet(style):
def main():
exit_code = 0
pool_terminated = False
def term(pool):
def handler(e):
print(e)
pool.terminate()
nonlocal exit_code
exit_code = 1
nonlocal pool_terminated
pool_terminated = True
return handler
......@@ -221,14 +220,14 @@ def main():
p.apply_async(slice_font, (style, source, weight, *options), {'italic': False}, error_callback=term(p))
p.apply_async(slice_font, (style, source, weight, *options), {'italic': True}, error_callback=term(p))
generate_stylesheet(style)
p.apply_async(generate_stylesheet, (style,), error_callback=term(p))
p.close()
p.join()
if exit_code:
# pool has been terminated, exit with error code
sys.exit(exit_code)
if pool_terminated:
# pool has been terminated, raise an exception
raise Exception
if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment