Commits

Anonymous committed 6483e53

Reduce cpu usage with delay option and add python 2.5 compatibility.

The delay option used a tight loop for the delay period, simply sleep
for the delay period and pick up any extra events a single time at the
end.

Added support for python 2.5 by adding the with statement from future.

  • Participants
  • Parent commits c9a68a9

Comments (0)

Files changed (1)

+from __future__ import with_statement
+
 from constants import *
 import inotifyx
 import subprocess
             # Block until events arrive.
             events = inotifyx.get_events(self.fd)
 
-            # Continue collecting events for the delay period.  This
-            # allows events that occur close to the trigger event to be
-            # collected now rather than causing another run immediately
-            # after this run.
-            end = time.time() + self.delay
-            while time.time() < end:
+            # Collect any events that occur within the delay period.
+            # This allows events that occur close to the trigger event
+            # to be collected now rather than causing another run
+            # immediately after this run.
+            if self.delay:
+                time.sleep(self.delay)
                 events.extend(inotifyx.get_events(self.fd, 0))
 
             # Filter to events that are white listed.