freshcrate
Home > Frameworks > watchfiles

watchfiles

Simple, modern and high performance file watching and code reload in python.

Description

# watchfiles [![CI](https://github.com/samuelcolvin/watchfiles/actions/workflows/ci.yml/badge.svg)](https://github.com/samuelcolvin/watchfiles/actions/workflows/ci.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/samuelcolvin/watchfiles/branch/main/graph/badge.svg)](https://codecov.io/gh/samuelcolvin/watchfiles) [![pypi](https://img.shields.io/pypi/v/watchfiles.svg)](https://pypi.python.org/pypi/watchfiles) [![CondaForge](https://img.shields.io/conda/v/conda-forge/watchfiles.svg)](https://anaconda.org/conda-forge/watchfiles) [![license](https://img.shields.io/github/license/samuelcolvin/watchfiles.svg)](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.9 - 3.14. ```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 ```

Release History

VersionChangesUrgencyDate
1.1.1Imported from PyPI (1.1.1)Low4/21/2026
v1.1.1## What's Changed * Add support for Python 3.14 on windows builds by @zerocewl in https://github.com/samuelcolvin/watchfiles/pull/352 * prepare for v1.1.1 release by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/353 ## New Contributors * @zerocewl made their first contribution in https://github.com/samuelcolvin/watchfiles/pull/352 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v1.1.0...v1.1.1Low10/14/2025
v1.1.0## What's Changed * Bump `crossbeam-channel` from 0.5.12 to 0.5.15 by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/336 * skip flakey test on windows by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/342 * Update notify dependency to 8.0.0, bumping MSRV to 1.77 by @musicinmybrain in https://github.com/samuelcolvin/watchfiles/pull/327 * Update PyO3 to 0.25.1 by @musicinmybrain in https://github.com/samuelcolvin/watchfiles/pull/340 * test and build with 3.14Low6/15/2025
v1.0.5## What's Changed * Bump pyo3 from 0.23.3 to 0.24.1 by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/333 * use `uv publish --trusted-publishing`, remove twine check by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/334 * uprev to 1.0.5 by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/335 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v1.0.4...v1.0.5Low4/8/2025
v1.0.4## What's Changed * Fix badge for CI by @ofek in https://github.com/samuelcolvin/watchfiles/pull/323 * Fix data loss issue by ensuring proper locking and clearing of changes by @koseki2580 in https://github.com/samuelcolvin/watchfiles/pull/314 * Bump jinja2 from 3.1.4 to 3.1.5 in /requirements by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/321 * Use notify 7.0.0 instead of a fork of 6.1.1 by @musicinmybrain in https://github.com/samuelcolvin/watchfiles/pull/322 * switch tLow1/10/2025
v1.0.3try to fix docs deploy 946a29616ef555b313249b51038ff1b51e2e97ec **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v1.0.2...v1.0.3Low12/10/2024
v1.0.2Fix PyPI asset upload from v1.0.1. **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v1.0.1...v1.0.2Low12/10/2024
v1.0.1## What's Changed * Bump dawidd6/action-download-artifact from 2 to 6 in /.github/workflows by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/311 * Bump pyo3 from 0.23.1 to 0.23.3 by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/317 * bump to PyO3 0.23.3 by @davidhewitt in https://github.com/samuelcolvin/watchfiles/pull/316 ## New Contributors * @davidhewitt made their first contribution in https://github.com/samuelcolvin/watchfiles/pull/316 **Full ChanLow12/10/2024
v1.0.0## What's Changed * Bump PyO3 to 0.23, drop Python 3.8 support by @gi0baro in https://github.com/samuelcolvin/watchfiles/pull/307 * allow modify `poll_delay_ms` argument using an environment variable by @joelpelaez in https://github.com/samuelcolvin/watchfiles/pull/303 * remove set_version, prepare for v1 release by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/309 * fix version check and release in CI by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/310Low11/25/2024
v0.24.0## What's Changed * drop PyPy 3.8 by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/293 * Update Python version in `index.md` by @kjaymiller in https://github.com/samuelcolvin/watchfiles/pull/296 * return "file deleted" instead of raising an exception, fix https://github.com/samuelcolvin/watchfiles/pull/282 by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/301 ## New Contributors * @kjaymiller made their first contribution in https://github.com/samuelcoLow8/28/2024
v0.23.0## What's Changed * Fix typo in `watch` doctstring by @kwentine in https://github.com/samuelcolvin/watchfiles/pull/280 * Bump up PyO3 to 0.22.2 by @FlickerSoul in https://github.com/samuelcolvin/watchfiles/pull/287 * Updates to GitHub Actions by @gaby in https://github.com/samuelcolvin/watchfiles/pull/274 * Update mkdocstring python handler option key by @kwentine in https://github.com/samuelcolvin/watchfiles/pull/281 * Bump requests from 2.31.0 to 2.32.0 in /requirements by @dependabot in Low8/7/2024
v0.22.0## What's Changed * fix `list-pypi-files` CI task by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/250 * pip show wrong homepage by @NewUserHa in https://github.com/samuelcolvin/watchfiles/pull/253 * Update PyO3 by @mgorny in https://github.com/samuelcolvin/watchfiles/pull/267 * Delete setup.py by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/260 * really drop python<=3.7 support by @kloczek in https://github.com/samuelcolvin/watchfiles/pull/264 * upreLow5/27/2024
v0.21.0## What's Changed * Add Python 3.12 support, drop Python 3.7 support by @gi0baro in https://github.com/samuelcolvin/watchfiles/pull/248 ## New Contributors * @gi0baro made their first contribution in https://github.com/samuelcolvin/watchfiles/pull/248 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.20.0...v0.21.0Low10/13/2023
v0.20.0## What's Changed * Bump pymdown-extensions from 9.5 to 10.0 in /requirements by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/229 * Bump pygments from 2.13.0 to 2.15.0 in /requirements by @dependabot in https://github.com/samuelcolvin/watchfiles/pull/237 * Allow maturin 1.x by @heirecka in https://github.com/samuelcolvin/watchfiles/pull/233 * Fix: Memory leak of PyO3 by @koseki2580 in https://github.com/samuelcolvin/watchfiles/pull/240 * Improve debug by @samuelcolvin in hLow8/24/2023
v0.19.0## What's Changed * Better error on OS watcher limit by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/208 * Reduce CI jobs by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/209 * build wheels for ppc64le and s390x by @messense in https://github.com/samuelcolvin/watchfiles/pull/210 * Switch flake8->ruff by @TheoBabilon in https://github.com/samuelcolvin/watchfiles/pull/212 * Simplify Change.raw_str() by @davidbrochart in https://github.com/samuelcolvin/waLow3/27/2023
v0.18.1* fix command split on Windows by @Kulothungan16 in https://github.com/samuelcolvin/watchfiles/pull/199 * uprev pyo3, relax anyio constraint by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/203 * switch pytest-sugar -> pytest-pretty by @samuelcolvin in https://github.com/samuelcolvin/watchfiles/pull/204 ## New Contributors * @Kulothungan16 made their first contribution in https://github.com/samuelcolvin/watchfiles/pull/199 **Full Changelog**: https://github.com/samuelLow11/7/2022
v0.18.0* remove python caching in CI #191 * Add mypy, pytest cache to default exclude list #189 * configure sdist assets #93 * Force polling on WSL #194 * increase default polling delay to 300ms #196 * add CI check job and add 3.11 classifier #197 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.17.0...v0.18.0Low10/19/2022
v0.17.0* test with python 3.11, #179 & #180 * CI against python 3.11 rc1, #180 * uprev notify to 5.0.0-pre.16, #182 * Add option to disable recursion by @bvanelli in #183 * upgrade to notify 5.0.0, #184 * Lock all requirements, #185 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.16.1...v0.17.0Low9/11/2022
v0.16.1* Add missing source distribution (`sdist`) to PyI, fix #175 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.16.0...v0.16.1Low7/25/2022
v0.16.0* Docs for `.pyi` #165 * make `RustNotify` a context manager and kill the thread on exit #164 * Build PyPy wheels for Linux and macOS by @messense in #168 * Support `WATCHFILES_FORCE_POLLING` env var #170 * fallback to poll watcher on OS Error 38 #172 * test against python 3.11.0-beta.4 #173 * `--verbose` argument and improve bug template #174 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.15.0...v0.16.0Low7/21/2022
v0.15.0This release is just [v0.15a1](https://github.com/samuelcolvin/watchfiles/releases/tag/v0.15.0a1) promoted to a full release. * ~~uprev docker/setup-qemu-action #151~~ superceded by #158 * ~~set `CIBW_ENVIRONMENT_LINUX=true` #56~~ superceded by #158 * build with old rust #150 * Expose process kill timeouts and ensure sigkills are attempted by @tedivm in #153 * Switch from `setuptools-rust` to `maturin` by @messense in #158 * tweak build-dev and CI #159 * update binaries list in readme aLow6/17/2022
v0.15.0a1* ~~uprev docker/setup-qemu-action #151~~ superceded by #158 * ~~set `CIBW_ENVIRONMENT_LINUX=true` #56~~ superceded by #158 * build with old rust #150 * Expose process kill timeouts and ensure sigkills are attempted by @tedivm in #153 * Switch from `setuptools-rust` to `maturin` by @messense in #158 * tweak build-dev and CI #159 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.14.1...v0.15.0a1 Low6/3/2022
v0.14.1* test on python 3.11 #143 * Switch to notify `5.0.0-pre.15`, pin notify version #146 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.14...v0.14.1Low5/17/2022
v0.14**Potential Breaking Change:** due to changes in #136, `awatch` and therefore `arun_process` can nolonger catch and suppress `KeyboardInterupt`, you may need to catch this error where you call `asyncio.run()` or equivilant. ## What's Changed * Update docs for conda install by @davidbrochart in #124 * fix file renaming on macOS #123 * remove redundant `wheel` requirement from `pyproject.toml` by @mgorny in #126 * Build manylinux2014 wheels for CentOS 7 support by @TBBle in #131 * uprev crLow5/16/2022
v0.13* improve docs 4328ea1 & 62994db * Add conda-forge install instructions to documentation by @davidbrochart in #117 * allow timeout in rust, add `rust_timeout` and `yield_on_timeout` kwargs to `watch` and `awatch` #113 * Fix tracking of file renaming/moving on Linux and Windows #119 * Add `aarch64` binaries for linux #121 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.12...v0.13Low4/8/2022
v0.12Allow `watch` to take a `stop_event` #112. **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.11...v0.12Low4/1/2022
v0.8.2* Add message about package renaming in readme * switch to pypi classifier `Development Status :: 7 - Inactive`Low4/1/2022
v0.11* fix conflicting black versions by @Fronkan in #107 * fix file modifying on Windows #108 * Rework CLI and `run_process`/`arun_process` to support either python functions for shell commands, #106 & #109 **Full Changelog**: https://github.com/samuelcolvin/watchfiles/compare/v0.10...v0.11Low3/30/2022
v0.10* Rewrite the whole thing to use rust notify * rename from `watchgod` to `watchfiles` * Write full api docs with mkdocs BoomLow3/23/2022
v0.10a1Rewrite the whole thing to use rust notify. #98. Boom.Low3/22/2022
v0.8.1## What's Changed * Allow any Event by @Dreamsorcerer in #99 * correct kwarg name with cli #101 **Full Changelog**: https://github.com/samuelcolvin/watchgod/compare/v0.8...v0.8.1Low3/21/2022
v0.8* Add installation instructions by @nurpax in #79 * Don't spam warnings on expected exceptions by @pbiggar in #82 * Add support for Python 3.10 by @joshuadavidthomas in #87 * uprev dependencies #97 * Add `anyio` dependency by @Kludex in #94 * Make sure new code is loaded when reloading process on file changes by @lephuongbg in #92 * Added `--extensions` argument by @AminRezaei0x443 in #86 **Full Changelog**: https://github.com/samuelcolvin/watchgod/compare/v0.7...v0.8Low3/14/2022
v0.7* 10-100x speedup by reusing `stat` for each file checked #75 * type hints, mypy checking and PEP-561 marker #58 & #77 * ability to ignore certain paths using CLI argument #60 * catch Ctrl-C on `run_process` #74 * add Emacs temporary files to default ignore list #70 * README docs improvements #57, #63 & #73 * apply "black" formatting 38434c3 * move from travis to github-actions #76 * add "Sponsor" button bf89db5 * update pypi classifiers cfd2b63 Low1/30/2021
v0.6* allow to watch signle file #52 * gracefully stop child processes #51 * add `MANIFEST.in` so `LICENCE` is included in `.tar.gz`, rewrite readme in markdown, tests for python 3.8 #54 * pass arguments to the target function #50Low3/8/2020
v0.5* change `RegExpWatcher` to allow `re_files` or `re_dirs` #34 * allow no tty device #42 * add CWD to python path, fix cli #43 * fix formatting and add tests for python 3.7 #44Low8/29/2019
v0.4* Fix `re_dirs` check in `RegExpWatcher` #23Low12/7/2018
v0.3* update dependencies * allow `watcher_kwargs` to `awatcher`, #22Low11/15/2018
v0.2* entirely rewrite `awatch` to better debounce changes * rewrite to use `awatch` in `watch` rather than duplicate logic * ignore directory not existing in check, fix #10Low5/11/2018
v0.1.1fix executorLow4/6/2018
v0.1Add `stop_event` to iterators.Low4/6/2018
v0.0.3Add CLI.Low10/19/2017
v0.0.2Release v0.0.2Low10/18/2017
v0.0.1Release v0.0.1Low10/17/2017

Dependencies & License Audit

Loading dependencies...

Similar Packages

pre-commitA framework for managing and maintaining multi-language pre-commit hooks.v4.6.0
azure-core-tracing-opentelemetryMicrosoft Azure Azure Core OpenTelemetry plugin Library for Pythonazure-template_0.1.0b6187637
spdx-toolsSPDX parser and tools.0.8.5
lacesDjango components that know how to render themselves.0.1.2
django-tasksA backport of Django's built in Tasks framework0.12.0