def waitLoaded(self): if not self.isLoaded_: self.ensureSubscribed() SharedStateSynchronizer.getSynchronizer().waitForKeyspaceAndPrefix( self.keyspaceName, NativeJson.Json(()) )
def setValueSlot(self, newValue): logging.info("Setting %s %s", str(self), newValue) if not self.keyspace.loaded: if SynchronousPropertyAccess.SynchronousPropertyAccess.getCurrent() is not None: self.keyspace.waitLoaded() else: logging.info("raising NotLoadedException for %s", self) raise NotLoadedException(self.keyspace) if newValue is None: SharedStateSynchronizer.getSynchronizer().writeValue( self.keyspace.keyspaceName, self.keyName, None ) else: assert isinstance(newValue, tuple) assert len(newValue) == 1 try: SharedStateSynchronizer.getSynchronizer().writeValue( self.keyspace.keyspaceName, self.keyName, JsonPickle.toJson(newValue[0]) ) except Exception as e: logging.error("%s", traceback.format_exc()) raise self.value_ = newValue
def setValueSlot(self, newValue): logging.info("Setting %s %s", str(self), newValue) if not self.keyspace.loaded: if SynchronousPropertyAccess.SynchronousPropertyAccess.getCurrent( ) is not None: self.keyspace.waitLoaded() else: logging.info("raising NotLoadedException for %s", self) raise NotLoadedException(self.keyspace) if newValue is None: SharedStateSynchronizer.getSynchronizer().writeValue( self.keyspace.keyspaceName, self.keyName, None) else: assert isinstance(newValue, tuple) assert len(newValue) == 1 try: SharedStateSynchronizer.getSynchronizer().writeValue( self.keyspace.keyspaceName, self.keyName, JsonPickle.toJson(newValue[0])) except Exception as e: logging.error("%s", traceback.format_exc()) raise self.value_ = newValue
def ensureSubscribed(self): assert SharedStateSynchronizer.isConnected() if not self.isSubscribed_: logging.info("ComputedGraphSharedState subscribing to: %s", self) SharedStateSynchronizer.getSynchronizer().addKeyspaceListener( self.keyspaceName, KeyspaceUpdater(self), NativeJson.Json(())) self.isSubscribed_ = True
def ensureSubscribed(self): assert SharedStateSynchronizer.isConnected() if not self.isSubscribed_: logging.info("ComputedGraphSharedState subscribing to: %s", self) SharedStateSynchronizer.getSynchronizer().addKeyspaceListener( self.keyspaceName, KeyspaceUpdater(self), NativeJson.Json(()) ) self.isSubscribed_ = True
def populateKey(self): keyspace, key = self.createKey() keyspace.waitLoaded() key.value = (self.keyValue,) SharedStateSynchronizer.getSynchronizer().update() SharedStateSynchronizer.getSynchronizer().commitPendingWrites() return key
def waitLoaded(self): if not self.isLoaded_: self.ensureSubscribed() SharedStateSynchronizer.getSynchronizer().waitForKeyspaceAndPrefix( self.keyspaceName, NativeJson.Json(()))