Mercurial > code > home > repos > homeauto
changeset 1395:6a8b922bbe2e
more state vars
Ignore-this: 5c5064141b82e35eecc82b0210c7db86
darcs-hash:63a2e7f662d8c4ab752a84860759fe6cc03377ce
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 06 Jul 2019 13:54:52 -0700 |
parents | b27d0f9a00ef |
children | 68fa0c41862b |
files | lib/patchablegraph/patchsource.py |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/patchablegraph/patchsource.py Sat Jul 06 00:49:12 2019 -0700 +++ b/lib/patchablegraph/patchsource.py Sat Jul 06 13:54:52 2019 -0700 @@ -1,4 +1,4 @@ -import logging +import logging, time import traceback from rdflib import ConjunctiveGraph from rdflib.parser import StringInputSource @@ -23,6 +23,8 @@ self._listeners = set() log.info('start read from %s', url) + self._startReadTime = time.time() + self._patchesReceived = 0 # including fullgraph # note: fullGraphReceived isn't guaranteed- the stream could # start with patches self._fullGraphReceived = False @@ -38,6 +40,13 @@ return { 'url': self.url, 'fullGraphReceived': self._fullGraphReceived, + 'patchesReceived': self._patchesReceived, + 'time': { + 'open': getattr(self, '_startReadTime', None), + 'fullGraph': getattr(self, '_fullGraphTime', None), + 'latestPatch': getattr(self, '_latestPatchTime', None), + }, + 'closed': self._eventSource is None, } def addPatchListener(self, func): @@ -76,6 +85,8 @@ log.error(traceback.format_exc()) raise self._fullGraphReceived = True + self._fullGraphTime = time.time() + self._patchesReceived += 1 def _onPatch(self, message): try: @@ -84,6 +95,8 @@ except: log.error(traceback.format_exc()) raise + self._latestPatchTime = time.time() + self._patchesReceived += 1 def _sendPatch(self, p, fullGraph): log.debug('PatchSource %s received patch %s (fullGraph=%s)',