watcher
¶
REFRESH_SECONDS
module-attribute
¶
How often the directories being watched are compared with the modules that are imported now.
DEBOUNCE_MS
module-attribute
¶
How long watchfiles waits for a burst of saves to settle before reporting them as one batch.
FileWatcher
dataclass
¶
FileWatcher(
path: Path,
on_change: Callable[[int], None],
on_stopped: Callable[[str], None] | None = None,
)
Watches the code a reload would pick up for *.py changes on a background thread and reports how many files changed in each batch.
path
instance-attribute
¶
path: Path
The project directory. It and the directories of the project's imported modules are watched, each on its own.
on_change
instance-attribute
¶
Called from the watcher's thread with the number of files that changed.
on_stopped
class-attribute
instance-attribute
¶
Called from the watcher's thread with the reason, if watching ends because of a failure. It is not called when stop ends it.
start
¶
Starts watching. Does nothing if already running.
Source code in src/mujoco_mojo/utils/layers/reloaded/watcher.py
watched_directories
¶
The directories to watch for a reload under root: root itself and the directory of every imported module that lives under it.
That is the same set of modules a reload acts on, and watching only their directories keeps the number of watches small. Watching everything under root also watches build trees, virtual environments, and checkouts that happen to sit beneath it, which can use up the operating system's whole allowance of watches.