atomicwrites
Atomic file writes.
What it is and what it does
Atomicwrites provides a simple context manager that ensures file writes complete fully or not at all, preventing corruption from interrupted writes or concurrent access. It works by writing to a temporary file in the same directory, then atomically moving it to the target location using platform-specific operations: rename on POSIX systems (with optional link-and-unlink for non-overwrite cases), and MoveFileEx on Windows via ctypes. The library includes fsync calls to flush both file content and directory metadata on POSIX systems, and _commit on Windows, though it does not guarantee protection against disk-level buffering.
The package has no runtime dependencies and supports Python 2.7 and 3.4 through 3.8 according to its classifiers. It is designed to be a lightweight, cross-platform alternative to manual temp-file-and-rename patterns, with a high-level API wrapping a flexible class-based interface. However, the project is abandoned and has not been updated since July 2022, meaning new Python versions, security issues, and platform changes will not be addressed.
Use it for:
- Writing configuration files or state that must not be left in a partial or corrupted state if the process crashes or is interrupted.
- Coordinating file updates across multiple processes or threads where a partially-written file could cause readers to fail or see inconsistent data.
- Ensuring database-like durability for single-file data stores or caches that require atomic all-or-nothing semantics.
- Cross-platform applications that need consistent atomic-write behavior on both POSIX and Windows without platform-specific code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a context manager for writing files atomically—writing to a temporary file first, then moving it to the target location in a single operation to prevent partial or corrupted writes.
No. The package is abandoned (last updated July 2022, repository archived) and will not receive security patches or compatibility fixes for modern Python versions. While the core functionality is simple and has no dependencies, the lack of maintenance makes it unsuitable for new projects. Consider using a maintained alternative or implementing atomic writes directly with tempfile and os.replace, which is available in the standard library.
Install
atomicwrites on PyPI
pip
pip install atomicwritesuv
uv add atomicwritespoetry
poetry add atomicwritesInstalling atomicwrites
Before you install
High install friction; the package is abandoned (last commit 2022-07-08, repository archived) and has not been updated in over 1498 days. No runtime dependencies, but the lack of maintenance means security issues or compatibility problems with newer Python versions will not be addressed.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or distribution in proprietary or commercial projects.
Quickstart
from atomicwrites import atomic_write
with atomic_write('foo.txt', overwrite=True) as f:
f.write('Hello world.')
Verify before relying
- Whether the package works reliably on modern Python versions (3.9+) given its abandonment since 2022.
- Whether Windows atomicity guarantees hold on current NTFS implementations, given the documented uncertainty in the MSDN comment cited.
- Whether fsync behavior on modern filesystems and SSDs provides the durability guarantees the documentation implies.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,498 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 4,753,299/month — #2,240 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: atomicwrites-1.4.1.tar.gz
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
atomicwrites-homeassistantProvides atomic file writes that ensure a file…
permissive · top 15,000 on PyPI
types-atomicwritesProvides type stubs for the atomicwrites…
permissive · top 15,000 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
DrissionRecordBuffers and writes data to files (xlsx, csv,…
permissive · top 15,000 on PyPI
django-read-onlyPrevents Django database write operations by…
permissive · top 15,000 on PyPI
pathlib-mateExtends Python's pathlib.Path with convenience…
permissive · top 5,000 on PyPI
azure-storage-fileProvides a Python client library to create,…
permissive · top 5,000 on PyPI
ephemeral-port-reserveReserves an ephemeral port reliably and…
permissive · top 15,000 on PyPI
burner-redisRuns a Redis-compatible in-process database…
permissive · top 5,000 on PyPI
pathtoolsProvides pattern matching and utility functions…
permissive · top 15,000 on PyPI