watchfiles watches paths and reloads or restarts Python processes when files change, with sync and async APIs.
Overview
watchfiles is a Python package for file system watching and developer-oriented code reload. OS notifications are delegated to the Notify Rust library, which handles platform integration and polling fallbacks; change debouncing is also handled in Rust for batched updates.
Synchronously, watch() iterates over change sets for one or more files or directories. Asynchronously, awatch() provides the same for asyncio code. runprocess() and arunprocess() restart a target function or process when watched paths change, which suits local development servers and scripts.
A CLI can run arbitrary commands and reload them when files under configured paths change. Prebuilt wheels are offered for common Linux, macOS, and Windows CPU architectures; source installs require a stable Rust toolchain. The project was formerly named watchgod and documents migration from that name.
watchfiles supports Python 3.10 through 3.15 per its documentation and is imported or invoked as a CLI rather than operated as deployed server software.
Key features
- Sync and async watch iterators
- Process reload on changes
- Rust Notify for OS events
- Debounced change batches
- CLI for command reloading
- Prebuilt binaries on major OSes
Use cases
- Dev server auto-reload
- Watching config or source trees
- Asyncio file change handling
- CLI-driven reload workflows