# HG changeset patch # User drewp@bigasterisk.com # Date 1685235320 25200 # Node ID bf5353908f3cdd8b7f00d681f10d4f3185017df8 # Parent a71e4272d808c1bac4e4fb8aab9a58cc81aca42e when SyncedGraph tries to clear the graph for a resync, don't attempt to send that patch out diff -r a71e4272d808 -r bf5353908f3c rdfdb/syncedgraph/syncedgraph_base.py --- a/rdfdb/syncedgraph/syncedgraph_base.py Sat May 27 17:38:13 2023 -0700 +++ b/rdfdb/syncedgraph/syncedgraph_base.py Sat May 27 17:55:20 2023 -0700 @@ -142,7 +142,7 @@ # correct but ineffecient-- better to wait until new connection and apply only the diff log.debug(f'graph has {len(self._graph)} . lets clear it') - await self.patch(Patch(delQuads=self._graph.quads())) + await self._patchLocally(Patch(delQuads=self._graph.quads())) log.info(f'cleared graph to {len(self._graph)} (should be 0)') log.error('graph is not updating- you need to restart') @@ -159,14 +159,21 @@ log.warn("not currently connected- dropping patch") return + debugKey = await self._patchLocally(p) + + log.debug('sendPatch') + await self.ws.send_str(p.jsonRepr) + log.debug('patch is done %s', debugKey) + + async def _patchLocally(self, p: Patch) -> str: + debugKey = '[id=%s]' % (id(p) % 1000) if p.isNoop(): log.info("skipping no-op patch") - return + return debugKey # 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. - debugKey = '[id=%s]' % (id(p) % 1000) log.debug("\napply local patch %s %s", debugKey, p) try: self._applyPatchLocally(p) @@ -175,9 +182,7 @@ raise _CorruptionNeedResync() log.debug('runDepsOnNewPatch') await self.runDepsOnNewPatch(p) - log.debug('sendPatch') - await self.ws.send_str(p.jsonRepr) - log.debug('patch is done %s', debugKey) + return debugKey async def suggestPrefixes(self, ctx, prefixes): """