MCPcopy
hub / github.com/subframe7536/maple-font / run_build

Function run_build

build.py:1450–1482  ·  view source on GitHub ↗

Run build tasks in parallel using ProcessPoolExecutor.

(
    pool_size: int, fn: Callable, dir: str, target_styles: list[str] | None = None
)

Source from the content-addressed store, hash-verified

1448
1449
1450def run_build(
1451 pool_size: int, fn: Callable, dir: str, target_styles: list[str] | None = None
1452):
1453 """Run build tasks in parallel using ProcessPoolExecutor."""
1454 if target_styles:
1455 files = []
1456 for f in listdir(dir):
1457 if f.split("-")[-1][:-4] in target_styles:
1458 files.append(f)
1459 elif "NF" not in f:
1460 remove(joinPaths(dir, f))
1461 else:
1462 files = listdir(dir)
1463
1464 if pool_size <= 1:
1465 for f in files:
1466 fn(f)
1467 return
1468
1469 first_exc: Exception | None = None
1470 with ProcessPoolExecutor(max_workers=pool_size) as executor:
1471 futures = {executor.submit(fn, f): f for f in files}
1472 for future in as_completed(futures):
1473 try:
1474 future.result()
1475 except Exception as e:
1476 # Optionally, cancel other futures if needed
1477 for f in futures:
1478 if not f.done():
1479 f.cancel()
1480 if not first_exc:
1481 first_exc = e
1482 raise e
1483
1484
1485def build_variable_fonts(font_config: FontConfig, build_option: BuildOption):

Callers 3

build_base_fontsFunction · 0.85
build_nerd_fontsFunction · 0.85
_build_cnFunction · 0.85

Calls 1

joinPathsFunction · 0.90

Tested by

no test coverage detected