Skip to main content

run_with_reloader

Runs a function with an auto-reloader that monitors file changes and restarts the process as needed. It handles termination signals, manages the execution environment via environment variables, and catches keyboard interrupts to exit gracefully.

def run_with_reloader(
main_func: callable,
*args: any,
**kwargs: any
) - > null

Runs the provided main function while monitoring the filesystem for changes, automatically restarting the process when a file modification is detected.

Parameters

NameTypeDescription
main_funccallableThe entry point function to be executed and monitored by the reloader.
*argsanyVariable positional arguments to be passed to the main_func.
**kwargsanyVariable keyword arguments to be passed to the main_func.

Returns

TypeDescription
nullThis function does not return a value; it manages the process lifecycle and exits the system upon completion or interruption.