def __init__(self, framework): if self.init: return self.init = True self.nextCycle = time.time() MainLoopApplication.__init__(self, framework) self.threadPool = ThreadPool(16, 0, 0, None) # # Class holding custom infos on the dispatcher. # This data can be periodically flushed in a specific log file for later use # self.cycle = 1 self.dispatchTree = DispatchTree() self.licenseManager = LicenseManager() self.enablePuliDB = settings.DB_ENABLE self.cleanDB = settings.DB_CLEAN_DATA self.pulidb = None if self.enablePuliDB: self.pulidb = PuliDB(self.cleanDB, self.licenseManager) self.dispatchTree.registerModelListeners() rnsAlreadyInitialized = self.initPoolsDataFromBackend() if self.enablePuliDB and not self.cleanDB: LOGGER.warning("reloading jobs from database") beginTime = time.time() self.pulidb.restoreStateFromDb(self.dispatchTree, rnsAlreadyInitialized) LOGGER.warning("reloading took %.2fs" % (time.time() - beginTime)) LOGGER.warning("done reloading jobs from database") LOGGER.warning("reloaded %d tasks" % len(self.dispatchTree.tasks)) LOGGER.warning("checking dispatcher state") self.dispatchTree.updateCompletionAndStatus() self.updateRenderNodes() self.dispatchTree.validateDependencies() if self.enablePuliDB and not self.cleanDB: self.dispatchTree.toModifyElements = [] self.defaultPool = self.dispatchTree.pools['default'] LOGGER.warning("loading dispatch rules") self.loadRules() # it should be better to have a maxsize self.queue = Queue(maxsize=10000)
def __init__(self, framework): if self.init: return self.init = True self.nextCycle = time.time() MainLoopApplication.__init__(self, framework) self.threadPool = ThreadPool(16, 0, 0, None) LOGGER.info('settings.DEBUG = %s', settings.DEBUG) LOGGER.info('settings.ADDRESS = %s', settings.ADDRESS) LOGGER.info('settings.PORT = %s', settings.PORT) self.cycle = 1 self.dispatchTree = DispatchTree() self.licenseManager = LicenseManager() self.enablePuliDB = settings.DB_ENABLE self.cleanDB = settings.DB_CLEAN_DATA self.pulidb = None if self.enablePuliDB: self.pulidb = PuliDB(self.cleanDB, self.licenseManager) self.dispatchTree.registerModelListeners() rnsAlreadyInitialized = self.initPoolsDataFromBackend() if self.enablePuliDB and not self.cleanDB: LOGGER.info("reloading jobs from database") beginTime = time.time() self.pulidb.restoreStateFromDb(self.dispatchTree, rnsAlreadyInitialized) LOGGER.info("reloading took %s" % str(time.time() - beginTime)) LOGGER.info("done reloading jobs from database") LOGGER.info("reloaded %d tasks" % len(self.dispatchTree.tasks)) LOGGER.info("checking dispatcher state") self.dispatchTree.updateCompletionAndStatus() self.updateRenderNodes() self.dispatchTree.validateDependencies() if self.enablePuliDB and not self.cleanDB: self.dispatchTree.toModifyElements = [] self.defaultPool = self.dispatchTree.pools['default'] LOGGER.info("loading dispatch rules") self.loadRules() # it should be better to have a maxsize self.queue = Queue(maxsize=10000)
def __init__(self, framework): LOGGER = logging.getLogger('main.dispatcher') if self.init: return self.init = True self.nextCycle = time.time() MainLoopApplication.__init__(self, framework) self.threadPool = ThreadPool(16, 0, 0, None) # # Class holding custom infos on the dispatcher. # This data can be periodically flushed in a specific log file for # later use # self.cycle = 1 self.dispatchTree = DispatchTree() self.licenseManager = LicenseManager() self.enablePuliDB = settings.DB_ENABLE self.cleanDB = settings.DB_CLEAN_DATA self.restartService = False self.pulidb = None if self.enablePuliDB: self.pulidb = PuliDB(self.cleanDB, self.licenseManager) self.dispatchTree.registerModelListeners() rnsAlreadyInitialized = self.initPoolsDataFromBackend() if self.enablePuliDB and not self.cleanDB: LOGGER.warning("--- Reloading database (9 steps) ---") prevTimer = time.time() self.pulidb.restoreStateFromDb(self.dispatchTree, rnsAlreadyInitialized) LOGGER.warning("%d jobs reloaded from database" % len(self.dispatchTree.tasks)) LOGGER.warning("Total time elapsed %s" % elapsedTimeToString(prevTimer)) LOGGER.warning("") LOGGER.warning("--- Checking dispatcher state (3 steps) ---") startTimer = time.time() LOGGER.warning("1/3 Update completion and status") self.dispatchTree.updateCompletionAndStatus() LOGGER.warning(" Elapsed time %s" % elapsedTimeToString(startTimer)) prevTimer = time.time() LOGGER.warning("2/3 Update rendernodes") self.updateRenderNodes() LOGGER.warning(" Elapsed time %s" % elapsedTimeToString(prevTimer)) prevTimer = time.time() LOGGER.warning("3/3 Validate dependencies") self.dispatchTree.validateDependencies() LOGGER.warning(" Elapsed time %s" % elapsedTimeToString(prevTimer)) LOGGER.warning("Total time elapsed %s" % elapsedTimeToString(startTimer)) LOGGER.warning("") if self.enablePuliDB and not self.cleanDB: self.dispatchTree.toModifyElements = [] # If no 'default' pool exists, create default pool # When creating a pool with id=None, it is automatically appended in "toCreateElement" list in dispatcher and in the dispatcher's "pools" attribute if 'default' not in self.dispatchTree.pools: pool = Pool(None, name='default') LOGGER.warning( "Default pool was not loaded from DB, create a new default pool: %s" % pool) self.defaultPool = self.dispatchTree.pools['default'] LOGGER.warning("--- Loading dispatch rules ---") startTimer = time.time() self.loadRules() LOGGER.warning("Total time elapsed %s" % elapsedTimeToString(startTimer)) LOGGER.warning("") # it should be better to have a maxsize self.queue = Queue(maxsize=10000)
def __init__(self, framework): if self.init: return self.init = True self.nextCycle = time.time() MainLoopApplication.__init__(self, framework) self.threadPool = ThreadPool(16, 0, 0, None) # # Class holding custom infos on the dispatcher. # This data can be periodically flushed in a specific log file for # later use # self.cycle = 1 self.dispatchTree = DispatchTree() self.licenseManager = LicenseManager() self.enablePuliDB = settings.DB_ENABLE self.cleanDB = settings.DB_CLEAN_DATA self.restartService = False self.pulidb = None if self.enablePuliDB: self.pulidb = PuliDB(self.cleanDB, self.licenseManager) self.dispatchTree.registerModelListeners() rnsAlreadyInitialized = self.initPoolsDataFromBackend() if self.enablePuliDB and not self.cleanDB: log.warning("--- Reloading database (9 steps) ---") prevTimer = time.time() self.pulidb.restoreStateFromDb(self.dispatchTree, rnsAlreadyInitialized) log.warning("%d jobs reloaded from database" % len(self.dispatchTree.tasks)) log.warning("Total time elapsed %s" % elapsedTimeToString(prevTimer)) log.warning("") log.warning("--- Checking dispatcher state (3 steps) ---") startTimer = time.time() log.warning("1/3 Update completion and status") self.dispatchTree.updateCompletionAndStatus() log.warning(" Elapsed time %s" % elapsedTimeToString(startTimer)) prevTimer = time.time() log.warning("2/3 Update rendernodes") self.updateRenderNodes() log.warning(" Elapsed time %s" % elapsedTimeToString(prevTimer)) prevTimer = time.time() log.warning("3/3 Validate dependencies") self.dispatchTree.validateDependencies() log.warning(" Elapsed time %s" % elapsedTimeToString(prevTimer)) log.warning("Total time elapsed %s" % elapsedTimeToString(startTimer)) log.warning("") if self.enablePuliDB and not self.cleanDB: self.dispatchTree.toModifyElements = [] # If no 'default' pool exists, create default pool # When creating a pool with id=None, it is automatically appended in "toCreateElement" list in dispatcher and in the dispatcher's "pools" attribute if 'default' not in self.dispatchTree.pools: pool = Pool(None, name='default') log.warning("Default pool was not loaded from DB, create a new default pool: %s" % pool) self.defaultPool = self.dispatchTree.pools['default'] log.warning("--- Loading dispatch rules ---") startTimer = time.time() self.loadRules() log.warning("Total time elapsed %s" % elapsedTimeToString(startTimer)) log.warning("") # it should be better to have a maxsize self.queue = Queue(maxsize=10000)