Mercurial > code > home > repos > rdfdb
changeset 128:bf5353908f3c
when SyncedGraph tries to clear the graph for a resync, don't attempt to send that patch out
author | drewp@bigasterisk.com |
---|---|
date | Sat, 27 May 2023 17:55:20 -0700 |
parents | a71e4272d808 |
children | 69ba5b86ce6c |
files | rdfdb/syncedgraph/syncedgraph_base.py |
diffstat | 1 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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): """