watchdog.utils.event_debouncer

watchdog.utils.event_debouncer#

class watchdog.utils.event_debouncer.EventDebouncer(debounce_interval_seconds: int, events_callback: Callable[[list[FileSystemEvent]], None])[source]#

Bases: BaseThread

Background thread for debouncing event handling.

When an event is received, wait until the configured debounce interval passes before calling the callback. If additional events are received before the interval passes, reset the timer and keep waiting. When the debouncing interval passes, the callback will be called with a list of events in the order in which they were received.

Parameters:
  • debounce_interval_seconds (int) – The number of seconds to wait before calling the callback.

  • events_callback (Callable[[list[FileSystemEvent]], None]) – The callback function to be invoked with the debounced events.

run() None[source]#

Runs the event loop that waits for incoming filesystem events and triggers the callback once the debounce interval has passed.

stop() None[source]#

Signals the thread to stop.