本文整理汇总了Python中ThreadPool.ThreadPool.getAllWorkerObjects方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadPool.getAllWorkerObjects方法的具体用法?Python ThreadPool.getAllWorkerObjects怎么用?Python ThreadPool.getAllWorkerObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadPool.ThreadPool
的用法示例。
在下文中一共展示了ThreadPool.getAllWorkerObjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildGivenPackages
# 需要导入模块: from ThreadPool import ThreadPool [as 别名]
# 或者: from ThreadPool.ThreadPool import getAllWorkerObjects [as 别名]
def buildGivenPackages (self, listPackages):
returnVal=self.calculateParams(listPackages)
if not returnVal:
self.logger.error("Unable to set paramaters. Terminating the package manager.")
return False
statusEvent=threading.Event()
numWorkerThreads=self.calculatePossibleNumWorkerThreads()
if numWorkerThreads > 8:
numWorkerThreads = 8
if numWorkerThreads == 0:
return False
self.initializeScheduler(statusEvent)
self.initializeThreadPool(statusEvent)
i=0
while i < numWorkerThreads:
workerName="WorkerThread"+str(i)
ThreadPool.addWorkerThread(workerName)
ThreadPool.startWorkerThread(workerName)
i = i + 1
statusEvent.wait()
Scheduler.stopScheduling=True
self.logger.info("Waiting for all remaining worker threads")
listWorkerObjs=ThreadPool.getAllWorkerObjects()
for w in listWorkerObjs:
w.join()
setFailFlag=False
allPackagesBuilt=False
if Scheduler.isAnyPackagesFailedToBuild():
setFailFlag=True
if Scheduler.isAllPackagesBuilt():
allPackagesBuilt=True
if setFailFlag:
self.logger.error("Some of the packages failed:")
self.logger.error(Scheduler.listOfFailedPackages)
return False
if not setFailFlag:
if allPackagesBuilt:
self.logger.info("All packages built successfully")
else:
self.logger.error("Build stopped unexpectedly.Unknown error.")
return False
self.logger.info("Terminated")
return True
示例2: buildGivenPackages
# 需要导入模块: from ThreadPool import ThreadPool [as 别名]
# 或者: from ThreadPool.ThreadPool import getAllWorkerObjects [as 别名]
def buildGivenPackages (self, listPackages, buildThreads):
if constants.rpmCheck:
alreadyBuiltRPMS=self.readAlreadyAvailablePackages()
listPackages=list(set(listPackages)|(set(constants.listMakeCheckRPMPkgtoInstall)-set(alreadyBuiltRPMS)))
returnVal=self.calculateParams(listPackages)
if not returnVal:
self.logger.error("Unable to set paramaters. Terminating the package manager.")
raise Exception("Unable to set paramaters")
statusEvent=threading.Event()
self.initializeScheduler(statusEvent)
self.initializeThreadPool(statusEvent)
i=0
while i < buildThreads:
workerName="WorkerThread"+str(i)
ThreadPool.addWorkerThread(workerName)
ThreadPool.startWorkerThread(workerName)
i = i + 1
statusEvent.wait()
Scheduler.stopScheduling=True
self.logger.info("Waiting for all remaining worker threads")
listWorkerObjs=ThreadPool.getAllWorkerObjects()
for w in listWorkerObjs:
w.join()
setFailFlag=False
allPackagesBuilt=False
if Scheduler.isAnyPackagesFailedToBuild():
setFailFlag=True
if Scheduler.isAllPackagesBuilt():
allPackagesBuilt=True
if setFailFlag:
self.logger.error("Some of the packages failed:")
self.logger.error(Scheduler.listOfFailedPackages)
raise Exception("Failed during building package")
if not setFailFlag:
if allPackagesBuilt:
self.logger.info("All packages built successfully")
else:
self.logger.error("Build stopped unexpectedly.Unknown error.")
raise Exception("Unknown error")
self.logger.info("Terminated")