Skip to main content

🔁 Automatically restart application when file changes are detected; made for development

Project description

py-mon

A modern, easy-to-use package to automatically restart a Python application when file changes are detected!

Quickstart (10s)

pip install -U py-mon
pymon app.py

Zero-config reloads for Python files by default. Requires Python 3.9+.

Why py-mon?

  • Works for Python files or any shell command (-x "npm run dev").
  • Simple patterns for watch/ignore; sane defaults.
  • Clean/quiet mode available when you don’t want prompts.

Core flags

  • -w / --watch <pattern>: what to watch (default *.py).
  • -i / --ignore <pattern>: what to ignore.
  • -x / --exec: run a shell command instead of python <file>.
  • -d / --debug: print changed paths.
  • -c / --clean: no logs, no stdin commands.
  • --delay <ms>: wait this long after the last change before restarting (default 250), so editor save bursts trigger one restart.

Command Input

When running pymon, you can use these commands:

  • Type rs to manually restart the process
  • Type stop to terminate pymon

If stdin is not available (e.g. running in CI or under a process manager), pymon keeps watching with command input disabled. When pymon stops or restarts your program, it terminates the whole process group, so shell commands started with -x don't leave stray child processes behind.

Optional Config File

Put a .pymonrc or pymon.json in your project root to keep team settings consistent:

{
  "watch": ["*.py", "config/*.yaml"],
  "ignore": ["*__pycache__*", "*.log"],
  "debug": false,
  "clean": false,
  "exec": false,
  "delay": 250
}

Command line arguments will always override config file settings.

__pycache__, .pyc/.pyo files and .git internals are always ignored, in addition to any ignore patterns you set.

Anyway that's basically it! Thanks for everything, I would appreciate it if you could leave a follow or star this repository ❣️ If you have any feature requests, read below!

Contributing

This package is open source so anyone with adequate Python experience can contribute to this project!

Report Issues

If you find any issues with the package or in the code, please create an issue and report it here!

Fix/Edit Content

If you want to contribute to this package, fork the repository, clone it, make your changes and then proceed to create a pull request here

Tests

Run the test suite locally with pytest:

pip install -e ".[dev]"
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_mon-2.3.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_mon-2.3.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file py_mon-2.3.0.tar.gz.

File metadata

  • Download URL: py_mon-2.3.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for py_mon-2.3.0.tar.gz
Algorithm Hash digest
SHA256 d76c6d0d2e05a0650afb756d4d350800726d0262e90862fe98dae65eadfe9427
MD5 9766fc22bdec5d0c33effb083f8277aa
BLAKE2b-256 42f2790342e781a20bb79920647872a8d6085e523225b188ebb76fa2a38aad12

See more details on using hashes here.

File details

Details for the file py_mon-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: py_mon-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for py_mon-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2320f7bd748644805c2dd5364f406c1d308937b08964987c2460e874f207c121
MD5 843c20851331580d54cf7d4dae234d79
BLAKE2b-256 11bc61c9b7cbd59e6004c4edd6dbcd128005e56f509c58888beafc6f8f882121

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page