aiofiles is a Python library that provides file support for asyncio applications.
Ordinary local file IO is blocking and cannot be made asynchronous without difficulty, which means file operations can interfere with asyncio applications by blocking the executing thread. aiofiles solves this by wrapping the standard file API and delegating blocking operations to a separate thread pool executor, allowing them to be awaited as coroutines. The library mirrors Python's standard blocking file interface closely, supporting buffered and unbuffered binary files as well as buffered text files, and includes async iteration support.
The tool suits any asyncio application that needs to perform local disk file operations without blocking the event loop. Its API is nearly identical to Python's built-in open function, making adoption straightforward for developers already familiar with standard file handling. Beyond basic file operations, aiofiles provides async wrappers for the tempfile module and an os submodule containing executor-enabled coroutine versions of filesystem operations like stat, rename, mkdir, listdir, and path checks. For testing, the library allows mocking by patching the underlying sync_open function.
The project maintains a stable, focused codebase with contributions welcomed and tested through tox. Development activity shows consistent attention to test coverage maintenance as a requirement for pull requests.