changeset 895:de9b9d0eed62

try to cull out SyncedGraph.patch calls where the patch is a no-op Ignore-this: 139d15a635d85b506d5d0d3a60b6f307
author Drew Perttula <drewp@bigasterisk.com>
date Sun, 09 Jun 2013 01:06:43 +0000
parents 836ea837cae9
children d5fd119a9acf
files light9/rdfdb/patch.py light9/rdfdb/syncedgraph.py
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/light9/rdfdb/patch.py	Sun Jun 09 01:02:13 2013 +0000
+++ b/light9/rdfdb/patch.py	Sun Jun 09 01:06:43 2013 +0000
@@ -143,6 +143,10 @@
         assert isinstance(ctx, URIRef), ctx
         return ctx
 
+    def isNoop(self):
+        return set(self.addQuads) == set(self.delQuads)
+            
+
 stmt1 = U('http://a'), U('http://b'), U('http://c'), U('http://ctx1')
 
 class TestPatchFromDiff(unittest.TestCase):
--- a/light9/rdfdb/syncedgraph.py	Sun Jun 09 01:02:13 2013 +0000
+++ b/light9/rdfdb/syncedgraph.py	Sun Jun 09 01:06:43 2013 +0000
@@ -99,6 +99,10 @@
         """send this patch to the server and apply it to our local
         graph and run handlers"""
 
+        if p.isNoop():
+            log.info("skipping no-op patch")
+            return
+        
         # these could fail if we're out of sync. One approach:
         # Rerequest the full state from the server, try the patch
         # again after that, then give up.