Registry /
serialization / atomicwrites-homeassistant
Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.014s · 17.8MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.5s · import 0.011s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
atomic_write
✓ from atomicwrites import atomic_write
This example demonstrates how to use `atomic_write` as a context manager to ensure that file writing is an atomic operation. The `overwrite=True` parameter ensures that if the file already exists, it will be safely replaced.
from atomicwrites import atomic_write
file_path = 'my_atomic_file.txt'
content = 'Hello, atomic world!'
# Perform an atomic write, overwriting if the file exists
with atomic_write(file_path, overwrite=True) as f:
f.write(content)
print(f"Content written to {file_path} atomically.")
Debug
Known issues
gotchaThe `atomicwrites-homeassistant` package is a fork created because the original `atomicwrites` library was unmaintained. Users should be aware they are using this Home Assistant-specific fork, which provides continued maintenance.fixEnsure you are installing `atomicwrites-homeassistant` when intending to use the Home Assistant-maintained version.
affects: All versions
gotchaOn Windows, the atomicity guarantee for file moves (using `MoveFileEx` via `ctypes`) is not absolute; it may silently fall back to a non-atomic method in some cases. If strict atomicity is critical on Windows, additional safeguards or alternative methods may be required.fixDo not solely rely on the library for guaranteed atomicity on Windows without additional validation or error handling for critical operations. Consider alternative strategies if absolute atomicity is a must-have.
affects: All versions
gotchaWhen running Home Assistant in Docker and using individually bind-mounted configuration files (e.g., for automations or scripts), atomic writes can lead to an `OSError: [Errno 16] Resource busy`. This prevents UI editors from saving changes to these files.fixTo resolve this, avoid bind-mounting individual configuration files. Instead, bind-mount the parent directory (e.g., `/config`) or use Docker volumes. Alternatively, edit these files directly on the host or accept that UI editing will not work for bind-mounted files.
affects: All versions with Docker bind mounts
gotchaOn POSIX systems, there is a small time window during `link` and `unlink` operations where the file might be accessible under both its temporary name and the target name. Additionally, file permissions of the target file may change and are not automatically preserved by the library due to concurrency concerns.fixBe aware of potential dual file entries during a brief transition period. If preserving specific permissions is crucial, implement explicit `chmod` calls after the atomic write, considering concurrency implications.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'atomicwrites_homeassistant'
The 'atomicwrites-homeassistant' package is not installed in the Python environment.
fixInstall the package using pip: 'pip install atomicwrites-homeassistant'.
ImportError: cannot import name 'atomic_write' from 'atomicwrites_homeassistant'
The module is named 'atomicwrites', not 'atomicwrites_homeassistant'.
fixUse the correct import statement: 'from atomicwrites import atomic_write'.
ModuleNotFoundError: No module named 'sqlalchemy'
The 'sqlalchemy' package is not installed, which is a dependency for some components.
fixInstall the package using pip: 'pip install sqlalchemy'.
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: 'RECORD'
Insufficient permissions to write to the installation directory.
fixRun the installation command with elevated privileges: 'sudo pip install homeassistant'.
ModuleNotFoundError: No module named '_sqlite3'
The Python installation lacks the SQLite module, which is required for database operations.
fixReinstall Python ensuring that the SQLite development headers are present during compilation.
Upgrade
Version history
1.4.1latest on PyPI · released Jul 8, 2022
Audit
Dependencies
No dependency data recorded yet.