Poller
A wrapper of threading.Thread to poll a function periodically.
- class duetector.tools.poller.Poller(config: dict[str, Any] | None = None, *args, **kwargs)[source]
Bases:
ConfiguableA wrapper for
threading.Thread- Special config:
interval_ms: Polling interval in milliseconds
- property call_when_shutdown
Whether to call
funcwhen shutdown
- config_scope: str | None = 'poller'
Config scope for this poller.
- default_config = {'call_when_shutdown': True, 'interval_ms': 500}
Default config for this poller.
- property interval_ms
Polling interval in milliseconds
- shutdown()[source]
Shutdown poller thread. It’s safe to call this method multiple times.
After shutdown,
waitshould be called to wait for the thread to exit.