Creates a daemon that calls the callback function at fixed intervals.
Arguments: - callback: The function to call at each interval. - interval: Number of seconds between callbacks. - verbose: Whether to print status messages.
Returns:: A (start, stop) function pair for the daemon.
import tempfilefrom pathlib import Pathdef my_callback():print("Interval callback!")start, stop, wait_for_stop = create_interval_daemon(tempfile.mktemp(), my_callback, interval=2.0, verbose=True)start() # Will print "Interval callback!" every 2 secondsstop() # Stops the daemon
[interval_daemon] Daemon started with 2.0s interval
Interval callback!
Starts a background daemon that watches folder_paths for changes.
Calls callback(event) whenever a file changes.
Arguments: - folder_paths: A path or list of paths to watch. - callback: The function to call when a file changes. Receives the event as argument. - recursive: Whether to watch folders recursively. - lock_file: Optional path to a lock file to ensure only one daemon is running. - rate_limit: Minimum number of seconds between callbacks.
Returns:: A (start, stop) function pair for the daemon.