From 4d5abf3bd1422758217d0ea0177df24d8aa98401 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 14 Nov 2026 20:26:59 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=204=20=F0=9F=9F=A1=20(0=20misread);=20reword=20HELD,=20Refused?= =?UTF-8?q?,=20heavy=5Fslot,=20ensure=5Fimage=20and=20the=20past-the-docum?= =?UTF-8?q?ents=20refusal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/adf_codec/convert.py | 10 +++++----- bin/machine_load/slots.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/adf_codec/convert.py b/bin/adf_codec/convert.py index a0e86cc7..02fb5afd 100644 --- a/bin/adf_codec/convert.py +++ b/bin/adf_codec/convert.py @@ -41,7 +41,7 @@ Slot = typing.Callable[[], typing.ContextManager[Failure | None]] @dataclasses.dataclass(frozen=True) class Refused: - """adf-codec refused the document at index of those handed to adfs_to_markdown.""" + """Why adf-codec refused one of the documents handed to adfs_to_markdown, and that document's index among them.""" index: int failure: Failure @@ -70,7 +70,7 @@ def docker(args: list[str], text: str, seconds: int, call: typing.Callable[..., @contextlib.contextmanager def heavy_slot(env: typing.Mapping[str, str] = os.environ, slots: int | None = None) -> typing.Iterator[Failure | None]: - """Holds one of the machine's heavy slots, which run-heavy shares, for the with block; under run-heavy the process already holds one, so it waits for none.""" + """Holds one of the machine's heavy slots, which run-heavy shares, for the with block. Under run-heavy the process already holds one, so it doesn't wait.""" if HELD in env: yield None return @@ -78,7 +78,7 @@ def heavy_slot(env: typing.Mapping[str, str] = os.environ, slots: int | None = N count = slot_count(usable_cpus()) if slots is None else slots try: folder.mkdir(parents=True, exist_ok=True) - _, fd = waited_slot(folder, count, lambda: print(f"adf-codec: waiting for a heavy slot, of {count} on this machine, to build the shim's image", file=sys.stderr, flush=True)) + _, fd = waited_slot(folder, count, lambda: print(f"adf-codec: waiting for a heavy slot, of {count} on this machine, in {folder}, to build the shim's image; `fuser {folder}/slot-*` names the processes that hold them", file=sys.stderr, flush=True)) except OSError as failure: yield Failure(f"cannot take a heavy slot in {folder}: {failure.strerror}") return @@ -91,7 +91,7 @@ def heavy_slot(env: typing.Mapping[str, str] = os.environ, slots: int | None = N def ensure_image(shim: pathlib.Path, run_docker: Docker = docker, slot: Slot = heavy_slot) -> str | Failure: """The tag of the image for the shim folder, built from that folder first where this machine has no image under that tag. - The build waits for a heavy slot, since `docker build` is heavy. Once the slot is held it looks again, as another process may have built the image meanwhile.""" + The build waits for a heavy slot. Once this process holds the slot, it inspects again, as another process may have built the image meanwhile.""" tag = image_tag(shim) found = image_found(tag, run_docker) if found is not False: @@ -169,7 +169,7 @@ def adfs_to_markdown(documents: list[dict[str, typing.Any]], run: Run = containe return [] out = answer("to-markdown", json.dumps(documents), run) if isinstance(out, Refused) and not 0 <= out.index < len(documents): - return Failure(f"the adf-codec shim refused document {out.index} of the {len(documents)} handed to it, counting from 0") + return Failure(f"the adf-codec shim refused a document at index {out.index}, past the {len(documents)} it was handed") if isinstance(out, Refused | Failure): return out try: diff --git a/bin/machine_load/slots.py b/bin/machine_load/slots.py index 749ae80d..74cbb255 100644 --- a/bin/machine_load/slots.py +++ b/bin/machine_load/slots.py @@ -8,7 +8,7 @@ import typing CPUS_PER_SLOT = 4 # Seconds between tries while every slot is held; a slot frees as its command exits. POLL_SECONDS = 1 -# The environment variable that tells a process it already holds a slot, which run-heavy sets for its command, so a step of a gate it runs doesn't wait on the gate's own slot. +# Names the environment variable run-heavy sets for the command it runs. A process that finds it set already holds a slot, and takes no second one. HELD = "RUN_HEAVY_SLOT"