Skip to content

Commit

Permalink
fixes EventDebouncer not producing events
Browse files Browse the repository at this point in the history
  • Loading branch information
ivg committed Aug 7, 2023
1 parent 75a3289 commit 8afb815
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/watchdog/utils/event_debouncer.py
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import time
import threading

from watchdog.utils import BaseThread
Expand Down Expand Up @@ -39,13 +40,16 @@ def stop(self):
def run(self):
with self._cond:
while True:
started = time.monotonic()
# Wait for first event (or shutdown).
self._cond.wait()

if self.debounce_interval_seconds:
# Wait for additional events (or shutdown) until the debounce interval passes.
while self.should_keep_running():
if not self._cond.wait(timeout=self.debounce_interval_seconds):
if self._cond.wait(timeout=self.debounce_interval_seconds):
if (time.monotonic() - started > self.debounce_interval_seconds):
break
else:
break

if not self.should_keep_running():
Expand Down

0 comments on commit 8afb815

Please sign in to comment.