Python threading._Condition() Examples

The following are 2 code examples of threading._Condition(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module threading , or try the search function .
Example #1
Source File: execution_status.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def get_number_of_waiting_threads(self):
        """
        A getter for the number of waiting threads
        :return:
        """
        # accessing a private member of a super class is ugly; a complete custom Condition implementation would be a
        # possible solution
        return len(self._Condition__waiters) 
Example #2
Source File: TrackingJobMaster.py    From biskit with GNU General Public License v3.0 5 votes vote down vote up
def getRst( self ):
        """
        Get data necessary for a restart of the running calculation.
        Locks, file handles and private data are *NOT* saved.
        Override if necessary but call this method in child method.

        @return: {..}, dict with 'pickleable' fields of master
        @rtype: dict
        """
        self.status.lock.acquire()

        ## collect master parameters that can be pickled
        rst = {}
        for k,v in self.__dict__.items():

            skip = 0
            for t in [ Thread, _RLock, _Condition, Status, file ]:
                if isinstance( v, t ):
                    skip = 1

            if str(k)[0] == '_':
                skip = 1

            if not skip:
                rst[k] = copy.copy( v )

        rst['status_objects'] = copy.deepcopy( self.status.objects )
        rst['master_class'] = self.__class__

        self.status.lock.release()

        return rst