当前位置: 首页>>代码示例>>Python>>正文


Python EDUtilsParallel.semaphoreNbThreadsAcquire方法代码示例

本文整理汇总了Python中EDUtilsParallel.EDUtilsParallel.semaphoreNbThreadsAcquire方法的典型用法代码示例。如果您正苦于以下问题:Python EDUtilsParallel.semaphoreNbThreadsAcquire方法的具体用法?Python EDUtilsParallel.semaphoreNbThreadsAcquire怎么用?Python EDUtilsParallel.semaphoreNbThreadsAcquire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EDUtilsParallel.EDUtilsParallel的用法示例。


在下文中一共展示了EDUtilsParallel.semaphoreNbThreadsAcquire方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from EDUtilsParallel import EDUtilsParallel [as 别名]
# 或者: from EDUtilsParallel.EDUtilsParallel import semaphoreNbThreadsAcquire [as 别名]
    def start(self, _strXmlInput):
        """
        Launch EDNA with the given XML stream
        @param _strXmlInput:  XML to be passed to the plugin
        @type  _strXmlInput: python string representing the XML data structure
        """
        if (_strXmlInput is None) or (_strXmlInput == "") :
            return
        #This is a trick to work-around bug #463:
        #  Run the fist thread alone (delay the second, third, ...)
        #    semaphore._Semaphore__value is the current value of the value, unfortunatly it is a protected value without getter 
        #    I need the value of the semaphore to guess if the current call is the first or not.
        #    Nota semaphore are decreased in value from self.__iNbThreads to 0. When Zero, the semaphore is blocking.
        # Them all other, limited by the semaphore.

        if self.__bIsFirstExecute:
            sys.stdout.write("Waiting for first thread to initialize ....")
            while EDUtilsParallel.getNbRunning() > 0:
                time.sleep(0.5)
                sys.stdout.write(".")
        EDUtilsParallel.semaphoreNbThreadsAcquire()

        edPlugin = EDParallelExecute.__edFactoryPlugin.loadPlugin(self.__strPluginName)

        if (edPlugin is not None):

            edPlugin.setDataInput(_strXmlInput)
            edPlugin.connectSUCCESS(self.successPluginExecution)
            edPlugin.connectFAILURE(self.failurePluginExecution)
            edPlugin.execute()
            #edPlugin.executeSynchronous()
        else:
            EDUtilsParallel.semaphoreNbThreadsRelease()
            self.__bIsFirstExecute = False
            EDVerbose.screen("ERROR! Plugin not found : " + self.__strPluginName)
开发者ID:antolinos,项目名称:edna,代码行数:37,代码来源:AverageRun.py

示例2: preProcess

# 需要导入模块: from EDUtilsParallel import EDUtilsParallel [as 别名]
# 或者: from EDUtilsParallel.EDUtilsParallel import semaphoreNbThreadsAcquire [as 别名]
 def preProcess(self, _edObject=None):
     """
     preProcess of the plugin:
     Ensure a CPU resource is available for the processing by acquiring a semaphore
     """
     EDVerbose.DEBUG("Acquire semaphore nbCPU by plugin %s, currently value: %s" % (self.getPluginName(), EDUtilsParallel.getSemaphoreValue()))
     EDUtilsParallel.semaphoreNbThreadsAcquire()
     EDPlugin.preProcess(self, _edObject)
开发者ID:olofsvensson,项目名称:edna-kernel,代码行数:10,代码来源:EDPluginExec.py

示例3: preProcess

# 需要导入模块: from EDUtilsParallel import EDUtilsParallel [as 别名]
# 或者: from EDUtilsParallel.EDUtilsParallel import semaphoreNbThreadsAcquire [as 别名]
 def preProcess(self, _edObject=None):
     """
     preProcess of the plugin:
     Ensure a CPU resource is available for the processing by acquiring a semaphore
     """
     self.DEBUG("Acquire semaphore nbCPU by plugin %s" % self.getPluginName())
     EDUtilsParallel.semaphoreNbThreadsAcquire()
     EDPlugin.preProcess(self, _edObject)
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:10,代码来源:EDPluginExec.py

示例4: semaphoreNbThreadsAcquire

# 需要导入模块: from EDUtilsParallel import EDUtilsParallel [as 别名]
# 或者: from EDUtilsParallel.EDUtilsParallel import semaphoreNbThreadsAcquire [as 别名]
 def semaphoreNbThreadsAcquire(self):
     """Method to acquire the semaphore that controls the number of threads running concurrently"""
     EDUtilsParallel.semaphoreNbThreadsAcquire()
开发者ID:antolinos,项目名称:edna,代码行数:5,代码来源:AverageRun.py


注:本文中的EDUtilsParallel.EDUtilsParallel.semaphoreNbThreadsAcquire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。