Mercurial > code > home > repos > rdfdb
changeset 123:4f8e1a447b12
logging
author | drewp@bigasterisk.com |
---|---|
date | Sat, 27 May 2023 17:31:33 -0700 |
parents | d7810d94b595 |
children | 6342adc438c5 |
files | rdfdb/patch.py rdfdb/service.py rdfdb/shared_graph.py rdfdb/syncedgraph/syncedgraph_base.py rdfdb/watched_files.py |
diffstat | 5 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rdfdb/patch.py Wed May 24 12:49:56 2023 -0700 +++ b/rdfdb/patch.py Sat May 27 17:31:33 2023 -0700 @@ -34,6 +34,11 @@ immutable the json representation includes the {"patch":...} wrapper + + Next version: + - patch is either adds or dels, not both + - patch has a timestamp for resolving winners + - everyone has queues that can be compressed if a later patches obsolete earlier ones """ def __init__(self, jsonRepr: Optional[str] = None, addQuads=None, delQuads=None, addGraph=None, delGraph=None):
--- a/rdfdb/service.py Wed May 24 12:49:56 2023 -0700 +++ b/rdfdb/service.py Sat May 27 17:31:33 2023 -0700 @@ -72,7 +72,7 @@ await websocket.close() async def on_disconnect(self, websocket, close_code): - log.info("bye ws client %r: %s", self.connectionId, close_code) + log.info("bye ws client %r: close_code=%s", self.connectionId, close_code) self.db.clientDisconnected(self.connectionId)
--- a/rdfdb/shared_graph.py Wed May 24 12:49:56 2023 -0700 +++ b/rdfdb/shared_graph.py Sat May 27 17:31:33 2023 -0700 @@ -87,8 +87,11 @@ while True: ev = await self.watchedGraphs.graphEditEvents.get() now = time.time() - if now - self.lastWriteFileToContext.get(ev.uri, 0) < .1: + dt = now - self.lastWriteFileToContext.get(ev.uri, 0) + log.debug(f'we wrote to this file {dt} sec ago') + if dt < .1: # probably a change due to our own write. this should be handled in watched_files, not here! + log.debug(f'edit too soon after write - ignoring') continue # log.info(f'last wrote file for {ev.uri} {now-self.lastWriteFileToContext.get(ev.uri, 0)} sec ago') prev = self.graph.getSubgraph(ev.uri)
--- a/rdfdb/syncedgraph/syncedgraph_base.py Wed May 24 12:49:56 2023 -0700 +++ b/rdfdb/syncedgraph/syncedgraph_base.py Sat May 27 17:31:33 2023 -0700 @@ -122,7 +122,7 @@ j = json.loads(body) if 'connectedAs' in j: self.connectionId = j['connectedAs'] - log.info(f'rdfdb calls us {self.connectionId}') + log.info(f'connected to rdfdb as {self.connectionId}') elif 'patch' in j: p = Patch(jsonRepr=body) # todo: repeated parse log.debug("received patch %s", p.shortSummary()) @@ -132,8 +132,11 @@ async def _lostRdfdbConnection(self) -> None: self.isConnected = False + + # 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())) - log.info(f'cleared graph to {len(self._graph)}') + log.info(f'cleared graph to {len(self._graph)} (should be 0)') log.error('graph is not updating- you need to restart') async def _resync(self):
--- a/rdfdb/watched_files.py Wed May 24 12:49:56 2023 -0700 +++ b/rdfdb/watched_files.py Sat May 27 17:31:33 2023 -0700 @@ -55,7 +55,7 @@ self._convertEventsTask.cancel() def writeFile(self, p: Path, content: str): - + log.debug(f'writeFile {p.name} len={len(content)}') tmpOut = Path(str(p) + ".rdfdb-temp") tmpOut.write_text(content) @@ -134,6 +134,7 @@ async def _convertEvents(self): """get inotify events, emit FileEditEvents""" + log.info("start _covnertEvents- there should be 1 of these") while True: ev = await self._notifier.get() self._genEvent(ev, ev.path)