Skip to main content

StatReloader

This class monitors file system changes by periodically polling the modification times of watched files. It identifies updated files by comparing current snapshots against previous states and triggers notifications when changes are detected. The reloader operates on a fixed sleep interval and is designed to be universally available across different operating systems.

Attributes

AttributeTypeDescription
SLEEP_TIMEint = 1Check for changes once per second.

Constructor

Signature

def StatReloader() - > null

Methods


tick()

@classmethod
def tick() - > generator

Continuously monitors watched files for modifications by comparing current timestamps against previous snapshots and yields control after each check cycle. It triggers a file change notification whenever a file's modification time increases.

Returns

TypeDescription
generatorA generator that yields None after each sleep interval, allowing the caller to perform periodic tasks between file system checks.

snapshot_files()

@classmethod
def snapshot_files() - > generator

Generates a sequence of unique file paths and their corresponding modification times from the set of watched files. It filters out duplicate paths and safely ignores files that cannot be accessed or do not exist on the file system.

Returns

TypeDescription
generatorA generator yielding tuples containing the Path object and its floating-point modification timestamp.

check_availability()

@classmethod
def check_availability() - > boolean

Determines if the StatReloader is available for use in the current environment. This implementation always returns True as it relies on standard file system polling.

Returns

TypeDescription
booleanAlways returns True to indicate that the polling-based reloader is supported.