Registry / devops / hupper

hupper

JSON →
library1.12.1pypypi✓ verified 24d ago

hupper is an integrated process monitor for your Python process, designed for development. It automatically tracks changes to imported Python files and custom paths, restarting the process when files are modified. Reloads can also be triggered manually from code. It is currently at version 1.12.1 and maintains an active release cadence.

pip install hupper
INSTALL
IMPORT
SIG · HUPPER
H
hupper
devopspythonv1.12.1
Install
1.5s avg
Import
32ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.034s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.030s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

start_reloader
from hupper import start_reloader
is_active
from hupper import is_active
get_reloader
from hupper import get_reloader

To use hupper, define your application's entry point as a callable function. Call `hupper.start_reloader()` from your main script, passing the dotted path to this entry point. `hupper` will then fork a worker process to run your application and monitor for file changes. If changes are detected, the worker process will be restarted. The `HUPPER_RELOADER` environment variable distinguishes between the monitor and worker processes internally. Running the script and then modifying `my_app.py` will demonstrate the reload functionality.

import hupper import os import datetime import time def worker_func(): """This function contains the main application logic, re-executed on reload.""" now = datetime.datetime.now() print(f"Worker process active at {now}. Edit 'my_app.py' to trigger reload.") # In a real application, this would be your main application loop # (e.g., a web server, a background task). For this example, we just # sleep briefly to demonstrate the worker's lifecycle. try: while True: time.sleep(1) except KeyboardInterrupt: print("Worker received KeyboardInterrupt, shutting down.") def main(): if os.environ.get('HUPPER_RELOADER') != 'true': # This code runs in the *monitor* process print("Monitor: Starting reloader for 'my_app.worker_func'...") # The first call to start_reloader from the main process # forks a worker, starts monitoring, and never returns in this process. reloader = hupper.start_reloader('my_app.worker_func') # Optional: Watch additional files/directories # reloader.watch_files(['./config.ini']) print("Monitor: Reloader stopped.") # This line is usually not reached else: # This code runs in the *worker* process, after being forked by the monitor print("Worker: This is a reloaded worker process.") worker_func() if __name__ == '__main__': main()
hupper --version
Debug
Known issues
breakingVersion 1.11 dropped support for Python 2.7, 3.4, 3.5, and 3.6. Ensure your environment is Python 3.7 or newer.
fix
Upgrade your Python environment to 3.7+ before upgrading hupper to 1.11 or later.
affects: <1.11
gotchaThe `reload_interval` parameter, which controls how often the filesystem is scanned, must be set to a value greater than 0. Setting it to 0 or less could cause needless CPU spinning and is explicitly disallowed since version 1.11. The default is 1 second.
fix
Always ensure `reload_interval` is a positive integer or omit it to use the default.
affects: >=1.11
gotchaPrior to version 1.10, hupper's handling of SIGTERM signals could be problematic, especially in containerized environments like Docker. It would immediately shut down, potentially stranding the worker process.
fix
Upgrade to hupper 1.10 or later to benefit from improved SIGTERM handling, which gracefully forwards the signal to the child process.
affects: <1.10
gotchaThe `hupper.start_reloader()` function behaves differently based on whether it's called from the parent (monitor) process or a child (worker) process. When called initially from the parent, it forks a new worker, starts the monitor, and *never returns* in the parent process. When called from a worker process, it returns an `IReloaderProxy` instance to communicate with the monitor.
fix
Design your application's entry point to account for this dual behavior, typically by checking `os.environ.get('HUPPER_RELOADER')` or by structuring your `main` function as shown in the quickstart.
affects: All
gotchaYou can override hupper's default file monitor (which auto-selects between `watchdog` and `polling`) by setting the `HUPPER_DEFAULT_MONITOR` environment variable to a dotted Python path of an `IFileMonitorFactory` implementation (e.g., `hupper.polling.PollingFileMonitor`).
fix
Set the `HUPPER_DEFAULT_MONITOR` environment variable (e.g., `export HUPPER_DEFAULT_MONITOR=hupper.polling.PollingFileMonitor`) before running your hupper-monitored application if you need to force a specific monitoring mechanism.
affects: All
Errors
Common errors & fixes
ImportError: No module named 'hupper'
The `hupper` package is not installed in the Python environment where the application is being run, or the environment is not correctly activated.
fix
Install `hupper` using pip: `pip install hupper` or ensure your virtual environment is activated before running the application.
Connection in use: ('0.0.0.0', 8000)
When `hupper` attempts to reload an application, especially in containerized environments like Docker Compose, the previous process might not exit cleanly, leaving the port it was bound to (e.g., 8000) still in use. This prevents the new process from binding to the same port.
fix
Upgrade `hupper` to a newer version (e.g., beyond 1.7 if applicable, as older versions had issues with `stdin` in Docker) or ensure your application handles graceful shutdowns to release ports. Consider adding a `shutdown-interval` or ensuring `hupper` doesn't attempt to read from `stdin` in non-interactive environments if that's the underlying cause.
Upgrade
Version history
1.12.1latest on PyPI · released Jan 26, 2024
Audit
Dependencies
watchdogoptionalOptional dependency for more efficient file monitoring (inotify-style filesystem events) instead of polling.
Agent activity
9 hits · last 30 days
node
8
Resources