Simple, modern file watching and code reload in python.
Deprecated. Its authors have deprecated it and no longer maintain it.
pip install watchgodwatchgod
Simple, modern file watching and code reload in python.
NOTICE - Package Renamed to watchfiles
Please note: This package (watchgod) has been renamed to watchfiles.
Please replace watchgod with watchfiles, see the migration guide
for help and instructions on switching.
As well as a better name, watchfiles has a whole new backend based on rust-notify which makes watching
for filesystem events much more efficient.
The package under the name watchgod will not be further developed and will only receive critical security fixes.
Usage
To watch for changes in a directory:
from watchgod import watch
for changes in watch('./path/to/dir'):
print(changes)
To run a function and restart it when code changes:
from watchgod import run_process
def foobar(a, b, c):
...
run_process('./path/to/dir', foobar, args=(1, 2, 3))
run_process uses PythonWatcher so only changes to python files will prompt a
reload, see custom watchers below.
If you need notifications about change events as well as to restart a process you can
use the callback argument to pass a function which will be called on every file change
with one argument: the set of file changes.
Installation
pip install watchgod