phenotypic.sdk_.atomic_write_text#
- phenotypic.sdk_.atomic_write_text(path: str | Path, text: str, *, encoding: str = 'utf-8', pre_replace: Callable[[], None] | None = None) None[source]#
Atomically write
texttopath(temp sibling +os.replace).A drop-in replacement for
Path(path).write_text(text)that never leaves a half-written file: a concurrent reader sees either the old contents or the complete new ones, and an exception mid-write leaves any pre-existing file intact with no.tmpdebris.- Parameters:
- Raises:
OSError – If the write or rename fails (the temp file is removed first).
- Return type:
None