# HG changeset patch # User drewp@bigasterisk.com # Date 1580719878 28800 # Node ID 74ad667f8c5b21493cfd3e520edb8ec5148c5463 # Parent 83ccc9ba90ea190bcfbf6ca8e672aeb3fb44aece reformat Ignore-this: e1fe14c4b973c3c1fc2714b988ecc7c8 diff -r 83ccc9ba90ea -r 74ad667f8c5b lib/patchablegraph/patchablegraph.py --- a/lib/patchablegraph/patchablegraph.py Mon Feb 03 00:50:53 2020 -0800 +++ b/lib/patchablegraph/patchablegraph.py Mon Feb 03 00:51:18 2020 -0800 @@ -71,7 +71,7 @@ }}) patchAsJson = jsonFromPatch # deprecated name - + def patchFromJson(j): body = json.loads(j)['patch'] a = ConjunctiveGraph() @@ -128,7 +128,7 @@ self._observers.append(onPatch) self._currentObservers = len(self._observers) self._observersAdded += 1 - + def removeObserver(self, onPatch): try: self._observers.remove(onPatch) @@ -138,7 +138,7 @@ def setToGraph(self, newGraph): self.patch(Patch.fromDiff(self._graph, newGraph)) - + _sendSimpleGraph = scales.PmfStat('serve/simpleGraph') _sendFullGraph = scales.PmfStat('serve/events/sendFull') _sendPatch = scales.PmfStat('serve/events/sendPatch') @@ -146,7 +146,7 @@ class CycloneGraphHandler(PrettyErrorHandler, cyclone.web.RequestHandler): def initialize(self, masterGraph): self.masterGraph = masterGraph - + def get(self): with self.masterGraph._sendSimpleGraph.time(): writeGraphResponse(self, self.masterGraph, @@ -156,7 +156,7 @@ class CycloneGraphEventsHandler(cyclone.sse.SSEHandler): """ One session with one client. - + returns current graph plus future patches to keep remote version in sync with ours. @@ -180,7 +180,6 @@ # throttle and combine patches here- ideally we could see how # long the latency to the client is to make a better rate choice self.sendEvent(message=patchJson, event=b'patch') - + def unbind(self): self.masterGraph.removeObserver(self.onPatch) -