watcher ¶
File system watcher for hot reload system.
Classes:
-
FileSystemWatcherProtocol–Protocol for file system watchers.
-
CogWatcher–File system event handler for cog reloading.
-
FileWatcher–Manages file system watching for hot reload.
Classes¶
FileSystemWatcherProtocol ¶
CogWatcher ¶
CogWatcher(
config: HotReloadConfig,
reload_callback: Callable[[str], None],
base_dir: Path,
event_loop: AbstractEventLoop | None = None,
)
Bases: FileSystemEventHandler
File system event handler for cog reloading.
Initialize the cog watcher.
Parameters:
-
config(HotReloadConfig) –Hot reload configuration.
-
reload_callback(Callable[[str], None]) –Callback function to invoke when a reload is needed.
-
base_dir(Path) –Base directory to watch.
-
event_loop(AbstractEventLoop | None, default:None) –Event loop for async operations, by default None.
Methods:
-
should_process_file–Check if file should be processed based on patterns.
-
on_modified–Handle file modification events.
-
on_created–Handle file creation events.
-
on_deleted–Handle file deletion events.
FileWatcher ¶
FileWatcher(config: HotReloadConfig, reload_callback: Callable[[str], None])
Manages file system watching for hot reload.
Initialize the file watcher.
Parameters:
-
config(HotReloadConfig) –Hot reload configuration.
-
reload_callback(Callable[[str], None]) –Callback function to invoke when a reload is needed.
Methods:
-
start–Start file system watching.
-
stop–Stop file system watching.
-
is_running–Check if file watcher is running.