changeset 958:502f0d532fd0

try harder not to lose notifications on a file after one edit in emacs Ignore-this: a1dc276d1f953ec9978a10e9744c674a
author drewp@bigasterisk.com
date Sat, 15 Jun 2013 07:16:11 +0000
parents fa78048a3240
children 2eb1b1874929
files light9/rdfdb/graphfile.py
diffstat 1 files changed, 24 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/light9/rdfdb/graphfile.py	Sat Jun 15 07:06:59 2013 +0000
+++ b/light9/rdfdb/graphfile.py	Sat Jun 15 07:16:11 2013 +0000
@@ -58,33 +58,34 @@
         notifier.watch(FilePath(path), callbacks=[self.notify])
       
     def notify(self, notifier, filepath, mask):
-        maskNames = humanReadableMask(mask)
-        if maskNames[0] == 'delete_self':
-            if not filepath.exists():
-                log.info("%s delete_self", filepath)
-                self.fileGone()
+        try:
+            maskNames = humanReadableMask(mask)
+            if maskNames[0] == 'delete_self':
+                if not filepath.exists():
+                    log.info("%s delete_self", filepath)
+                    self.fileGone()
+                    return
+                else:
+                    log.warn("%s delete_self event but file is here. ignoring",
+                             filepath)
                 return
-            else:
-                log.warn("%s delete_self event but file is here. ignoring",
-                         filepath)
-            return
 
-        # we could filter these out in the watch() call, but I want
-        # the debugging
-        if maskNames[0] in ['open', 'access', 'close_nowrite', 'attrib']:
-            log.debug("%s %s event, ignoring" % (filepath, maskNames))
-            return
+            # we could filter these out in the watch() call, but I want
+            # the debugging
+            if maskNames[0] in ['open', 'access', 'close_nowrite', 'attrib']:
+                log.debug("%s %s event, ignoring" % (filepath, maskNames))
+                return
 
-        try:
-            if filepath.getModificationTime() == self.lastWriteTimestamp:
-                log.debug("%s changed, but we did this write", filepath)
+            try:
+                if filepath.getModificationTime() == self.lastWriteTimestamp:
+                    log.debug("%s changed, but we did this write", filepath)
+                    return
+            except OSError as e:
+                log.error("%s: %r" % (filepath, e))
                 return
-        except OSError as e:
-            log.error("%s: %r" % (filepath, e))
-            return
-            
-        log.info("%s needs reread because of %s event", filepath, maskNames)
-        try:
+
+            log.info("%s needs reread because of %s event", filepath, maskNames)
+
             self.reread()
         except Exception:
             traceback.print_exc()