Changeset - 66cd0340bd32
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 10 years ago 2015-06-14 18:37:42
drewp@bigasterisk.com
heavy logging
Ignore-this: 4241e92c17ba994503deb9aae7586d
2 files changed with 17 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/autodepgraphapi.py
Show inline comments
 
import logging
 
from rdflib import RDF, RDFS
 
from light9.rdfdb.currentstategraphapi import contextsForStatementNoWildcards
 
log = logging.getLogger('syncedgraph')
 
log = logging.getLogger('autodepgraphapi')
 

	
 
class AutoDepGraphApi(object):
 
    """
 
@@ -43,10 +43,12 @@ class AutoDepGraphApi(object):
 
        # it gives the same result, I don't call the handler?
 

	
 
        self.currentFuncs.append(func)
 
        log.debug('graph.currentFuncs push %s', func)
 
        try:
 
            func()
 
        finally:
 
            self.currentFuncs.pop()
 
            log.debug('graph.currentFuncs pop %s. stack now has %s', func, len(self.currentFuncs))
 

	
 
    def runDepsOnNewPatch(self, p):
 
        """
 
@@ -55,6 +57,7 @@ class AutoDepGraphApi(object):
 
        """
 
        for func in self._watchers.whoCares(p):
 
            # todo: forget the old handlers for this func
 
            log.debug('runDepsOnNewPatch calling watcher %s', p)
 
            self.addHandler(func)
 

	
 
    def _getCurrentFunc(self):
light9/rdfdb/syncedgraph.py
Show inline comments
 
@@ -82,6 +82,7 @@ class SyncedGraph(CurrentStateGraphApi, 
 
        should just fail them. There should be a notification back to
 
        UIs who want to show that we're doing a resync.
 
        """
 
        log.info('resync')
 
        self._sender.cancelAll()
 
        # this should be locked so only one resync goes on at once
 
        return cyclone.httpclient.fetch(
 
@@ -107,15 +108,24 @@ class SyncedGraph(CurrentStateGraphApi, 
 
        # 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.
 
        log.debug("apply local patch %s", p)
 
        debugKey = '[id=%s]' % (id(p) % 1000)
 
        print ''
 
        log.debug("apply local patch %s %s", debugKey, p)
 
        import traceback; traceback.print_stack()
 
        try:
 
            patchQuads(self._graph, p.delQuads, p.addQuads, perfect=True)
 
            patchQuads(self._graph,
 
                       deleteQuads=p.delQuads,
 
                       addQuads=p.addQuads,
 
                       perfect=True)
 
        except ValueError as e:
 
            log.error(e)
 
            self.sendFailed(None)
 
            return
 
        log.debug('runDepsOnNewPatch')
 
        self.runDepsOnNewPatch(p)
 
        log.debug('sendPatch')
 
        self._sender.sendPatch(p).addErrback(self.sendFailed)
 
        log.debug('patch is done %s', debugKey)
 

	
 
    def sendFailed(self, result):
 
        """
 
@@ -133,6 +143,7 @@ class SyncedGraph(CurrentStateGraphApi, 
 
        """
 
        central server has sent us a patch
 
        """
 
        log.debug('_onPatch server has sent us %s', p)
 
        patchQuads(self._graph, p.delQuads, p.addQuads, perfect=True)
 
        log.debug("graph now has %s statements" % len(self._graph))
 
        try:
0 comments (0 inline, 0 general)