fastware v0.6.0 /src.fastware._fswrite
On this page

Internal thread-safe file writer that serializes append and overwrite operations under a single lock, shared by the audit log and feature-flag store.

#src.fastware._fswrite

#src.fastware._fswrite

A small thread-safe file writer shared by the append/overwrite call sites.

Several modules persist small files with the same three-part shape: guard with a lock, create the parent directory tree on demand, then append or overwrite. :class:LockedFileWriter is that pattern extracted once so the audit log (append) and the feature-flag store (overwrite) do not each reimplement it.

#LockedFileWriter

Serialize writes to a single file, creating parent dirs on demand.

A single :class:threading.Lock serializes every write so concurrent callers never interleave bytes. The parent directory tree is created lazily on the first write, so callers need not pre-create it.

#append_line

python
def append_line(self, line: str) -> None

Append line followed by a newline, under the lock.

#overwrite

python
def overwrite(self, text: str) -> None

Replace the file's entire contents with text, under the lock.

Search