A modern, easy-to-use package to automatically restart Python applications when file changes are detected. Perfect for development workflows with full support for Docker, Vagrant, and mounted filesystems via polling mode.
- π Zero-config reloading - Works with Python files by default
- π Polling mode - Solves mounted filesystem limitations (Docker, Vagrant, CIFS/NFS)
- π― Flexible patterns - Watch and ignore patterns with glob support
- βοΈ Config file support -
.pyreloadrcorpyreload.jsonfor team settings - π§Ή Clean mode - No logs, no prompts for production-like testing
- π§ Exec mode - Run any shell command, not just Python files
- β¨οΈ Manual control - Type
rsto restart,stopto exit
pip install pyreload-cli
pyreload app.pyThat's it! Your app will restart automatically when Python files change.
If you're developing inside Docker, Vagrant, or using mounted filesystems:
pyreload app.py --pollingThe --polling flag enables filesystem polling, which works reliably with mounted volumes where OS-level file events don't propagate.
# Watch Python files (default)
pyreload app.py
# Watch multiple patterns
pyreload app.py -w "*.py" -w "*.yaml" -w "config/*.json"
# Ignore patterns
pyreload app.py -i "*__pycache__*" -i "*.log" -i ".git/*"
# Use polling for Docker/Vagrant
pyreload app.py --polling
# Execute shell command instead
pyreload -x "npm run dev"
# Debug mode - see file changes
pyreload app.py --debug
# Clean mode - no logs
pyreload app.py --cleanWhen pyreload is running, you can use these commands:
- Type
rsand press Enter to manually restart - Type
stopand press Enter to exit - Press
Ctrl+Cto exit immediately
Create a .pyreloadrc or pyreload.json in your project root:
{
"watch": ["*.py", "config/*.yaml"],
"ignore": ["*__pycache__*", "*.log", ".git/*"],
"debug": false,
"clean": false,
"exec": false,
"polling": false
}Command-line arguments always override config file settings.
Standard file watching uses OS-level events (like inotify on Linux). These events don't propagate through mounted volumes. When you edit a file on your host machine and it syncs to a Docker container or Vagrant VM, the kernel inside the container/VM never receives the file change event.
Polling mode solves this by directly checking file modification times at regular intervals instead of relying on OS events.
# Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["pyreload", "app.py", "--polling"]# docker-compose.yml
services:
app:
build: .
volumes:
- .:/app
command: pyreload app.py --polling# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.synced_folder ".", "/vagrant"
config.vm.provision "shell", inline: <<-SHELL
pip install pyreload
cd /vagrant
pyreload app.py --polling
SHELL
end| Option | Short | Description | Default |
|---|---|---|---|
--version |
-V |
Show version and exit | - |
--watch <pattern> |
-w |
Path/pattern to watch (can be used multiple times) | *.py |
--ignore <pattern> |
-i |
Pattern to ignore (can be used multiple times) | - |
--polling |
-p |
Use polling-based file watching | false |
--debug |
-d |
Log detected file changes | false |
--clean |
-c |
No logs, no commands (quiet mode) | false |
--exec |
-x |
Execute shell command instead of Python file | false |
Pyreload uses glob patterns for matching files:
*.py- All Python files in current directorysrc/*.py- Python files in src directorysrc/**/*.py- Python files in src and subdirectoriesconfig/*.{yaml,yml,json}- Config files (use multiple-wflags)*__pycache__*- Ignore Python cache (use with-i)
| Feature | Pyreload | py-mon | nodemon |
|---|---|---|---|
| Python-native | β | β | β |
| Polling mode | β | β | β |
| Config file | β | β | β |
| Docker/Vagrant support | β | β | |
| Zero dependencies* | β | β | β |
| Exec mode | β | β | β |
*Excluding watchdog and colorama
Contributions are welcome! This project is open source.
git clone https://github.com/dotbrains/pyreload-cli.git
cd pyreload-cli
# Quick setup (installs pre-commit hooks)
./setup-dev.sh
# Or manual setup
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pre-commit installpytestPre-commit hooks will automatically format on commit. To run manually:
pre-commit run --all-files
# Or manually:
black .
ruff check --fix .MIT License - see LICENSE file for details.
- Documentation: https://dotbrains.github.io/pyreload-cli
- PyPI: https://pypi.org/project/pyreload-cli
- GitHub: https://github.com/dotbrains/pyreload-cli
- Issues: https://github.com/dotbrains/pyreload-cli/issues
Inspired by py-mon and nodemon, built to solve the mounted filesystem limitation with polling support.
Made with β€οΈ by dotbrains