skillfed

atomicwrites

Atomic file writes.

atomicwrites v1.4.1 4.8M downloads/30d#2,240 on PyPI321
Permissive license MIT Abandoned released

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 atomicwrites

uv

uv add atomicwrites

poetry

poetry add atomicwrites

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPython

Tags

atomic file writesafe file writingtemporary file renameprevent partial writesrace-free file operationscross-platform atomic renamefsync file durability
file-ioabandoned

More Software Development packages