本文整理汇总了Python中EDUtilsParallel.EDUtilsParallel.getSemaphoreNbThreads方法的典型用法代码示例。如果您正苦于以下问题:Python EDUtilsParallel.getSemaphoreNbThreads方法的具体用法?Python EDUtilsParallel.getSemaphoreNbThreads怎么用?Python EDUtilsParallel.getSemaphoreNbThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EDUtilsParallel.EDUtilsParallel
的用法示例。
在下文中一共展示了EDUtilsParallel.getSemaphoreNbThreads方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: executeControlledPlugins
# 需要导入模块: from EDUtilsParallel import EDUtilsParallel [as 别名]
# 或者: from EDUtilsParallel.EDUtilsParallel import getSemaphoreNbThreads [as 别名]
def executeControlledPlugins(self):
"""
Execute all plugins under control:
"""
bAllFinished = False
while not bAllFinished:
#acquire all semaphores to be sure no plugins are under configuration !
for sem in self.lstSem:
with sem:
pass
if self.queue.empty():
self.synchronizePlugins()
bAllFinished = self.queue.empty()
else:
while not self.queue.empty():
try:
plugin = self.queue.get()
except Exception:
self.WARNING("In EDPluginControlAlignStackv1_0, exception in self.queue.get()")
break
else:
#this is a hack to prevent thousands of threads to be launched at once.
with EDUtilsParallel.getSemaphoreNbThreads():
pass
plugin.execute()
self.synchronizePlugins()