# HG changeset patch # User Drew Perttula # Date 1559419424 0 # Node ID 6b01e1e5859ba613a10b587b82ddaca38fb6312a # Parent 108260060f2c424d14cef2ab8bd447dca5520812 drop patches and log, but don't otherwise error, if we're not connected to rdfdb Ignore-this: bc95e8005e78e5d78e061cb6dc73668a diff -r 108260060f2c -r 6b01e1e5859b rdfdb/service.py --- a/rdfdb/service.py Sat Jun 01 20:03:05 2019 +0000 +++ b/rdfdb/service.py Sat Jun 01 20:03:44 2019 +0000 @@ -262,9 +262,9 @@ self.watchedFiles.dirtyFiles([ctx]) graphStats.statements = len(self.graph) - def _syncPatchToOtherClients(self, p: Patch, sender: str): + def _syncPatchToOtherClients(self, p: Patch, sender: Optional[str]=None): for c in self.clients: - if c.connectionId == sender: + if sender is not None and c.connectionId == sender: # this client has self-applied the patch already log.debug("_syncPatchToOtherClients: don't resend to %r", c) continue diff -r 108260060f2c -r 6b01e1e5859b rdfdb/syncedgraph.py --- a/rdfdb/syncedgraph.py Sat Jun 01 20:03:05 2019 +0000 +++ b/rdfdb/syncedgraph.py Sat Jun 01 20:03:44 2019 +0000 @@ -49,6 +49,7 @@ def onOpen(self): log.info('ws open') + self.sg.isConnected = True def onMessage(self, payload, isBinary): msg = json.loads(payload) @@ -77,6 +78,7 @@ def onClose(self, wasClean, code, reason): log.info("WebSocket connection closed: {0}".format(reason)) + self.sg.isConnected = False class SyncedGraph(CurrentStateGraphApi, AutoDepGraphApi, GraphEditApi): """ @@ -112,7 +114,8 @@ receiverHost is the hostname other nodes can use to talk to me """ - + self.isConnected = False + self.currentClient: Optional[WsClientProtocol] = None self.connectSocket(rdfdbRoot) self.rdfdbRoot = rdfdbRoot self.initiallySynced: defer.Deferred[None] = defer.Deferred() @@ -162,6 +165,10 @@ """send this patch to the server and apply it to our local graph and run handlers""" + if not self.isConnected or self.currentClient is None: + log.warn("not currently connected- dropping patch") + return + if p.isNoop(): log.info("skipping no-op patch") return