def run( self ): while self.__automaticUpdate: iWaitTime = gConfigurationData.getPropagationTime() time.sleep( iWaitTime ) if self.__refreshEnabled: if not self.__refreshAndPublish(): gLogger.error( "Can't refresh configuration from any source" )
def run(self): while self.__automaticUpdate: iWaitTime = gConfigurationData.getPropagationTime() time.sleep(iWaitTime) if self.__refreshEnabled: if not self.__refreshAndPublish(): gLogger.error("Can't refresh configuration from any source")
def test_configurationAutoUpdate(value1, value2): """ Test if service refresh his configuration. It sent a random value to the CS and check if Service can return it. """ csapi = CSAPI() # SETTING FIRST VALUE csapi.modifyValue("/DIRAC/Configuration/TestUpdateValue", value1) csapi.commitChanges() # Wait for automatic refresh (+1 to be sure that request is done) time.sleep(gConfigurationData.getPropagationTime() + 1) RPCClient("Framework/User").getTestValue() assert RPCClient("Framework/User").getTestValue()["Value"] == value1 # SETTING SECOND VALUE csapi.modifyValue("/DIRAC/Configuration/TestUpdateValue", value2) csapi.commitChanges() time.sleep(gConfigurationData.getPropagationTime() + 1) assert RPCClient("Framework/User").getTestValue()["Value"] == value2
def __refreshLoop(self): """ Trigger the autorefresh when configuration is expired This task must use Tornado utilities to avoid blocking the ioloop and potentialy deadlock the server. See http://www.tornadoweb.org/en/stable/guide/coroutines.html#looping for official documentation about this type of method. """ while self._automaticUpdate: # This is the sleep from Tornado, like a sleep it wait some time # But this version is non-blocking, so IOLoop can continue execution yield gen.sleep(gConfigurationData.getPropagationTime()) # Publish step is blocking so we have to run it in executor # If we are not doing it, when master try to ping we block the IOLoop yield _IOLoop.current().run_in_executor(None, self.__AutoRefresh)