Skip to content

Commit 127be54

Browse files
feat(parser): add flushing to output handling for immediate file writing
1 parent 00fc189 commit 127be54

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/dylan/parser/language_derivation.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,10 @@ def _write_layered_deduped(
932932
language_file: TextIO,
933933
seen_success: set[str],
934934
) -> int:
935-
"""Write a successful ``Sent:``/``Sem:`` block if unseen; discard non-success records."""
935+
"""Write a successful ``Sent:``/``Sem:`` block if unseen; discard non-success records.
936+
937+
Flushes the handle after writing so layered runs show incremental output on disk.
938+
"""
936939
if record.kind != "success":
937940
return 0
938941
key = record.sentence
@@ -941,6 +944,7 @@ def _write_layered_deduped(
941944
seen_success.add(key)
942945
language_file.write(f"Sent: {record.sentence}\n")
943946
language_file.write(f"Sem: {record.semantics}\n\n")
947+
language_file.flush()
944948
return 1
945949

946950
@staticmethod
@@ -951,13 +955,17 @@ def _write_extension_failure_deduped(
951955
word: str,
952956
prefix_words: tuple[str, ...],
953957
) -> int:
954-
"""Write one ``WORD | PREFIX`` extension-failure line when that line has not been written; return 1 if new."""
958+
"""Write one ``WORD | PREFIX`` extension-failure line when that line has not been written; return 1 if new.
959+
960+
Flushes the handle after writing so layered runs show incremental output on disk.
961+
"""
955962
so_far = " ".join(prefix_words)
956963
line = f"{word} | {so_far}"
957964
if line in seen_failure:
958965
return 0
959966
seen_failure.add(line)
960967
failures_file.write(f"{line}\n")
968+
failures_file.flush()
961969
return 1
962970

963971
@staticmethod

0 commit comments

Comments
 (0)