https://github.com/samuelcolvin/watchfiles
Simple, modern and fast file watching and code reload for Python, written in Rust
https://github.com/samuelcolvin/watchfiles
asyncio filesystem inotify inotifywatch notify python rust uvicorn
Last synced: 17 days ago
JSON representation
Simple, modern and fast file watching and code reload for Python, written in Rust
- Host: GitHub
- URL: https://github.com/samuelcolvin/watchfiles
- Owner: samuelcolvin
- License: mit
- Created: 2017-10-13T17:31:51.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2026-09-21T10:32:09.000Z (about 1 month ago)
- Last Synced: 2026-10-13T22:56:11.163Z (22 days ago)
- Topics: asyncio, filesystem, inotify, inotifywatch, notify, python, rust, uvicorn
- Language: Python
- Homepage: https://watchfiles.helpmanual.io
- Size: 2.15 MB
- Stars: 2,549
- Watchers: 15
- Forks: 150
- Open Issues: 50
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesomeLibrary - watchfiles - Simple, modern and fast file watching and code reload in python. (语言资源库 / python)
- fucking-awesome-python - watchfiles - Simple, modern and fast file watching and code reload in python. (File Manipulation)
- awesome-python-rs - watchfiles - Simple, modern, fast file watching and code reload, powered by Rust's `notify` crate. (File Watching & System Utilities)
- awesome-python - watchfiles - Simple, modern and fast file watching and code reload in python. (File Manipulation)
README
# watchfiles
[](https://github.com/samuelcolvin/watchfiles/actions/workflows/ci.yml?query=branch%3Amain)
[](https://codecov.io/gh/samuelcolvin/watchfiles)
[](https://pypi.python.org/pypi/watchfiles)
[](https://anaconda.org/conda-forge/watchfiles)
[](https://github.com/samuelcolvin/watchfiles/blob/main/LICENSE)
Simple, modern and high performance file watching and code reload in python.
---
**Documentation**: [watchfiles.helpmanual.io](https://watchfiles.helpmanual.io)
**Source Code**: [github.com/samuelcolvin/watchfiles](https://github.com/samuelcolvin/watchfiles)
---
Underlying file system notifications are handled by the [Notify](https://github.com/notify-rs/notify) rust library.
This package was previously named "watchgod",
see [the migration guide](https://watchfiles.helpmanual.io/migrating/) for more information.
## Installation
**watchfiles** requires Python 3.10 - 3.15.
```bash
pip install watchfiles
```
Binaries are available for most architectures on Linux, MacOS and Windows ([learn more](https://watchfiles.helpmanual.io/#installation)).
Otherwise, you can install from source which requires Rust stable to be installed.
## Usage
Here are some examples of what **watchfiles** can do:
### `watch` Usage
```py
from watchfiles import watch
for changes in watch('./path/to/dir'):
print(changes)
```
See [`watch` docs](https://watchfiles.helpmanual.io/api/watch/#watchfiles.watch) for more details.
### `awatch` Usage
```py
import asyncio
from watchfiles import awatch
async def main():
async for changes in awatch('/path/to/dir'):
print(changes)
asyncio.run(main())
```
See [`awatch` docs](https://watchfiles.helpmanual.io/api/watch/#watchfiles.awatch) for more details.
### `run_process` Usage
```py
from watchfiles import run_process
def foobar(a, b, c):
...
if __name__ == '__main__':
run_process('./path/to/dir', target=foobar, args=(1, 2, 3))
```
See [`run_process` docs](https://watchfiles.helpmanual.io/api/run_process/#watchfiles.run_process) for more details.
### `arun_process` Usage
```py
import asyncio
from watchfiles import arun_process
def foobar(a, b, c):
...
async def main():
await arun_process('./path/to/dir', target=foobar, args=(1, 2, 3))
if __name__ == '__main__':
asyncio.run(main())
```
See [`arun_process` docs](https://watchfiles.helpmanual.io/api/run_process/#watchfiles.arun_process) for more details.
## CLI
**watchfiles** also comes with a CLI for running and reloading code. To run `some command` when files in `src` change:
```
watchfiles "some command" src
```
For more information, see [the CLI docs](https://watchfiles.helpmanual.io/cli/).
Or run
```bash
watchfiles --help
```