Skip to content

watcher

File system watcher for hot reload system.

Classes:

Classes

FileSystemWatcherProtocol

Bases: Protocol

Protocol for file system watchers.

Methods:

  • start

    Start the file system watcher.

  • stop

    Stop the file system watcher.

Functions

start
Python
start() -> None

Start the file system watcher.

stop
Python
stop() -> None

Stop the file system watcher.

CogWatcher

Python
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:

Functions

should_process_file
Python
should_process_file(file_path: Path) -> bool

Check if file should be processed based on patterns.

Returns:

  • bool

    True if file should be processed, False otherwise.

on_modified
Python
on_modified(event: FileSystemEvent) -> None

Handle file modification events.

on_created
Python
on_created(event: FileSystemEvent) -> None

Handle file creation events.

on_deleted
Python
on_deleted(event: FileSystemEvent) -> None

Handle file deletion events.

FileWatcher

Python
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.

Functions

start
Python
start() -> None

Start file system watching.

Raises:

stop
Python
stop() -> None

Stop file system watching.

Raises:

is_running
Python
is_running() -> bool

Check if file watcher is running.

Returns:

  • bool

    True if watcher is running, False otherwise.

Functions