Watchdog
Introduction
The Watchdog Extension includes the WatchdogManager, enabling applications to easily monitor, and react to, changes in filesystem paths based on the filesystem events monitoring library Watchdog.
On application startup, the Watchdog Observer is automatically started and then upon application close, the observer thread is properly stopped and joined with the parent process before exit.
API References:
Requirements
Watchdog
Applications using Cement <3.0.8 should continue to include watchdog in their dependencies.
Platform Support
Unix/Linux
macOS
Windows
Configuration
Application Configuration Settings
This extension does not support any application level configuration settings.
Application Meta Options
This extension honors the following application meta options:
Option
Description
watchdog_paths
A list of tuples that are passed directly as arguments to WatchdogManager.add() (a shortcut equivalent to app.watchdog.add().
Hooks
This extension defines the following hooks:
watchdog_pre_start
Run first when App.watchdog.start() is called. The application object is passed as an argument. Nothing is expected in return.
watchdog_post_start
Run last when App.watchdog.start() is called. The application object is passed as an argument. Nothing is expected in return.
watchdog_pre_stop
Run first when App.watchdog.stop() is called. The application object is passed as an argument. Nothing is expected in return.
watchdog_post_stop
Run last when App.watchdog.stop() is called. The application object is passed as an argument. Nothing is expected in return.
watchdog_pre_join
Run first when App.watchdog.join() is called. The application object is passed as an argument. Nothing is expected in return.
watchdog_post_join
Run last when App.watchdog.join() is called. The application object is passed as an argument. Nothing is expected in return.
Usage
The following example uses the default WatchdogEventHandler that by default only logs all events to debug:
In the above example, nothing is printed to console. However you will see something like the following via debug logging:
To expand on the above example, we can add our own event handlers:
For full usage of Watchdog event handlers, refer to the Watchdog API Documentation.
Last updated