Mercurial > code > home > repos > light9
changeset 1189:f6c2da565760
try re-watching files that disappeared during editing
Ignore-this: 1d557e4a9322fdf2f8f80781f822f99e
author | drewp@bigasterisk.com |
---|---|
date | Sun, 15 Jun 2014 18:05:13 +0000 |
parents | 92ffad96fd8a |
children | 5e7acb866b9f |
files | light9/rdfdb/graphfile.py |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/rdfdb/graphfile.py Sun Jun 15 18:04:55 2014 +0000 +++ b/light9/rdfdb/graphfile.py Sun Jun 15 18:05:13 2014 +0000 @@ -44,6 +44,11 @@ self.flushDelay = 2 # seconds until we have to call flush() when dirty self.writeCall = None # or DelayedCall + self.notifier = notifier + self.addWatch() + + def addWatch(self): + # emacs save comes in as IN_MOVE_SELF, maybe # I was hoping not to watch IN_CHANGED and get lots of @@ -55,8 +60,9 @@ from twisted.internet.inotify import IN_CLOSE_WRITE, IN_MOVED_FROM, IN_MODIFY, IN_DELETE, IN_DELETE_SELF, IN_CHANGED - notifier.watch(FilePath(path), callbacks=[self.notify]) - + log.info("add watch on %s", self.path) + self.notifier.watch(FilePath(self.path), callbacks=[self.notify]) + def notify(self, notifier, filepath, mask): try: maskNames = humanReadableMask(mask) @@ -82,6 +88,9 @@ return except OSError as e: log.error("%s: %r" % (filepath, e)) + # getting OSError no such file, followed by no future reads + reactor.callLater(.5, self.addWatch) # ? + return log.info("%s needs reread because of %s event", filepath, maskNames)