espnet3.bin.atlas.core.utils.write_text_atomically
Less than 1 minute
espnet3.bin.atlas.core.utils.write_text_atomically
espnet3.bin.atlas.core.utils.write_text_atomically(path: Path, text: str) → None
Write text to a file atomically via a sibling temp file and rename.
Writes to a .tmp_* file in the same directory, then os.replace``s it onto ``path so readers never observe a partially written file. The temp file is removed if the write fails.
- Parameters:
- path – Destination file path; parent directories are created if needed.
- text – Text to write (UTF-8 encoded).
- Returns: None.
Example
>>> write_text_atomically(Path("study/program.md"), "# Goal\n")