changeset 112:be3ee1d50d28

cull some noisy logging, add design note
author drewp@bigasterisk.com
date Mon, 30 May 2022 23:01:50 -0700
parents 22d52df208aa
children a9d49b297529
files rdfdb/shared_graph.py rdfdb/watched_files.py
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rdfdb/shared_graph.py	Mon May 30 22:55:29 2022 -0700
+++ b/rdfdb/shared_graph.py	Mon May 30 23:01:50 2022 -0700
@@ -83,10 +83,13 @@
         while True:
             ev = await self.watchedGraphs.graphEditEvents.get()
             now = time.time()
-            if now - self.lastWriteFileToContext.get(ev.uri, 0) < .1:
-                # probably a change due to our own write. this should be handled in watched_files, not here!
+            dt = now - self.lastWriteFileToContext.get(ev.uri, 0)
+            if dt < .1:
+                # probably a change due to our own write. this should be handled
+                # in watched_files, not here! See watched_files.py _genReadEvent note.
                 continue
-            log.info(f'last wrote file for {ev.uri} {now-self.lastWriteFileToContext.get(ev.uri, 0)} sec ago')
+            if dt < 10000:
+                log.info(f'last wrote file for {ev.uri} {dt} sec ago')
             prev = self.graph.getSubgraph(ev.uri)
             new = list(ev.content)
             p = Patch.fromTriplesDiff(prev, new, ev.uri)
--- a/rdfdb/watched_files.py	Mon May 30 22:55:29 2022 -0700
+++ b/rdfdb/watched_files.py	Mon May 30 23:01:50 2022 -0700
@@ -148,6 +148,10 @@
             log.error(f'while making WatchEvent for file {p}')
             raise
         log.info('--> watchevent with content')
+        # todo: i now think this is the point we should realize that the content
+        #  is the same as what we 'recently' wrote to the file, and the caller
+        #  should not be bothered with an event. What is 'recently'? If the
+        #  file mtime matches our last write?
         self.fileEditEvents.put_nowait(FileEditEvent(path=p, content=content))
 
     def _genGoneEvent(self, p: Path):