Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
doc/html/
node_modules
.node-modules/
__pycache__/
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Working on lexical

webcpp's rules apply here: read the superproject's
[CODING-GUIDELINES.md](../../CODING-GUIDELINES.md)
(<https://github.com/webcpporg/webcpp/blob/main/CODING-GUIDELINES.md>), whose
chapter 15 gives lexical's design decisions with their reasons, and its
[AGENTS.md](../../AGENTS.md)
(<https://github.com/webcpporg/webcpp/blob/main/AGENTS.md>) first. This file
holds only what is specific to lexical.
Expand Down
15 changes: 11 additions & 4 deletions tools/generate_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import sys
import textwrap
import urllib.request
import uuid
from collections.abc import Iterator, Sequence
from pathlib import Path

Expand Down Expand Up @@ -99,11 +100,17 @@ def pinned_files(pinned: Path) -> tuple[str, dict[str, dict[str, str]]]:


def write(path: Path, data: bytes) -> None:
"""Writes the data at the path through a sibling file, so that no reader sees half of it."""
"""Writes the data at the path through a sibling file of its own, so that no reader sees half
of it, and two writers of one path, such as two generators filling one cache at once, never
rename each other's file: the last to finish wins, with the same checked bytes."""
path.parent.mkdir(parents=True, exist_ok=True)
partial = path.with_name(path.name + '.partial')
partial.write_bytes(data)
partial.replace(path)
partial = path.with_name(f'{path.name}.{uuid.uuid4().hex}.partial')
try:
partial.write_bytes(data)
partial.replace(path)
except BaseException:
partial.unlink(missing_ok=True)
raise


def checked(data: bytes, source: str, pinned: str) -> bytes:
Expand Down
Loading