From 5eb95be9e5b406a13db79a4886a4f2726757a8dc Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Tue, 15 Oct 2024 16:08:07 -0400 Subject: [PATCH] [ttx_diff] Retry normalizer on failure We have spurious normalizer failures sometimes, and this will now check for those cases and retry (up to five times) if they occur. --- resources/scripts/ttx_diff.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/resources/scripts/ttx_diff.py b/resources/scripts/ttx_diff.py index f2d04552..46b22946 100755 --- a/resources/scripts/ttx_diff.py +++ b/resources/scripts/ttx_diff.py @@ -46,6 +46,7 @@ from typing import MutableSequence from glyphsLib import GSFont from fontTools.designspaceLib import DesignSpaceDocument +import time _COMPARE_DEFAULTS = "default" @@ -121,11 +122,24 @@ def ttx(font_file: Path, can_skip: bool): return ttx_file -# generate a simple text repr for gpos for this font +# generate a simple text repr for gpos for this font, with retry def simple_gpos_output(cargo_manifest_path: Path, font_file: Path, out_path: Path, can_skip: bool): + NUM_RETRIES = 5 + for i in range(NUM_RETRIES+1): + try: + return simple_gpos_output_impl(cargo_manifest_path, font_file, out_path, can_skip) + except subprocess.CalledProcessError as e: + time.sleep(0.1) + if i >= NUM_RETRIES: + raise e + print(f"normalizer failed with code '{e.returncode}'', retrying", file=sys.stderr) + +def simple_gpos_output_impl(cargo_manifest_path: Path, font_file: Path, out_path: Path, can_skip: bool): if not (can_skip and out_path.is_file()): temppath = font_file.parent / "markkern.txt" cmd = [ + "timeout", + "10m", "cargo", "run", "--release",