From 2e64634ba5e77b5139875107de0fcfe07754950d Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Wed, 26 Dec 2007 19:47:54 -0800 Subject: [PATCH] Guard against inotify floods (such as when running make or switching branches) Signed-off by: David Aguilar --- ugitlibs/inotify.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ugitlibs/inotify.py b/ugitlibs/inotify.py index 3460bef..41f7981 100644 --- a/ugitlibs/inotify.py +++ b/ugitlibs/inotify.py @@ -4,13 +4,18 @@ import cmds from PyQt4.QtCore import QThread, SIGNAL from pyinotify import ProcessEvent from pyinotify import WatchManager, Notifier, EventsCodes +import time class FileSysEvent(ProcessEvent): def __init__(self, parent): ProcessEvent.__init__(self) self.parent = parent + self.last_event_time = time.time() def process_default(self, event): - self.parent.notify() + # Prevent notificaiton floods + if time.time() - self.last_event_time >= 1.0: + self.parent.notify() + self.last_event_time = time.time() class GitNotifier(QThread): def __init__(self, path): -- 2.11.4.GIT