# _reload

URL: /pounce/api/_reload/
Section: api
Description: File watcher for development mode (``--reload``).

Polls the application's source directory for changes and signals the
supervisor to restart workers when modifications are detected.

Uses stdlib ``pathlib`` + polling. Ignores ``__pycache__``, ``.git``,
``node_modules``, and common virtual environment directories.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/_reload/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_reload%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_reload%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_reload%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_reload%2Findex.txt)

Module

#
`_reload`

File watcher for development mode (`--reload`).

Polls the application's source directory for changes and signals the
supervisor to restart workers when modifications are detected.

Uses stdlib`pathlib` + polling. Ignores `__pycache__`, `.git`,
`node_modules`, and common virtual environment directories.

4Functions

## Functions

`_should_watch`

2

`bool`

▼

Check if a path should be watched for changes.

`def _should_watch(path: Path, extensions: frozenset[str] = _WATCH_EXTENSIONS) -> bool`

##### Parameters

Name
Type
Description

`path`
`Path`

`extensions`
`frozenset[str]`

Default:`_WATCH_EXTENSIONS`

##### Returns

`bool`

`_snapshot`

2

`dict[str, float]`

▼

Take a snapshot of file modification times.

`def _snapshot(directories: list[Path], extensions: frozenset[str] = _WATCH_EXTENSIONS) -> dict[str, float]`

##### Parameters

Name
Type
Description

`directories`
`list[Path]`

`extensions`
`frozenset[str]`

Default:`_WATCH_EXTENSIONS`

##### Returns

`dict[str, float]`

`detect_changes`

3

`tuple[set[str], dict[str…`

▼

Compare current state against a previous snapshot.

`def detect_changes(directories: list[Path], previous: dict[str, float], extensions: frozenset[str] = _WATCH_EXTENSIONS) -> tuple[set[str], dict[str, float]]`

##### Parameters

Name
Type
Description

`directories`
`list[Path]`

Directories to scan.

`previous`
`dict[str, float]`

Previous snapshot from`_snapshot()`.

`extensions`
`frozenset[str]`

File extensions to watch.

Default:`_WATCH_EXTENSIONS`

##### Returns

`tuple[set[str], dict[str, float]]`

`watch_for_changes`

5

`None`

▼

Poll directories for changes and call callback on detection.

This is a blockin…

`def watch_for_changes(directories: list[Path], callback: Callable[[], None], *, interval: float = 1.0, stop_event: threading.Event | None = None, extra_extensions: tuple[str, ...] = ()) -> None`

Poll directories for changes and call callback on detection.

This is a blocking function designed to run in a thread. It polls
at the given interval and calls`callback()`whenever changes
are detected.

##### Parameters

Name
Type
Description

`directories`
`list[Path]`

Directories to watch.

`callback`
`Callable[[], None]`

Called (with no args) when changes are detected.

`interval`
`float`

Polling interval in seconds (default: 1.0).

Default:`1.0`

`stop_event`
`threading.Event | None`

Optional threading.Event to stop the watcher.

Default:`None`

`extra_extensions`
`tuple[str, ...]`

Additional file extensions to watch beyond the built-in set. The built-in set already covers Python, config, and the common static-site authoring files (`.md`, `.html`, `.css`, `.js`, `.svg`); use this for anything further (e.g. `(".rst", ".scss")`).

Default:`()`
