def active_processes(self, use_cache=True):
        """Return a list of all active processes, pruning dead ones

        :rtype: list

        """
        LOGGER.debug('Checking active processes (cache: %s)', use_cache)
        if self.can_use_process_cache(use_cache):
            return self._active_cache[1]
        active_processes, dead_processes = list(), list()
        for consumer in self.consumers:
            processes = list(self.consumers[consumer].processes)
            for name in processes:
                child = self.get_consumer_process(consumer, name)
                if child is None:
                    dead_processes.append((consumer, name))
                elif child.pid is None:
                    dead_processes.append((consumer, name))
                    continue
                elif child.pid == self.pid:
                    continue
                try:
                    proc = psutil.Process(child.pid)
                except psutil.NoSuchProcess:
                    dead_processes.append((consumer, name))
                    continue

                if self.unresponsive[name] >= self.MAX_UNRESPONSIVE_COUNT:
                    LOGGER.info('Killing unresponsive consumer %s (%i): '
                                '%i misses',
                                name, proc.pid, self.unresponsive[name])
                    try:
                        os.kill(child.pid, signal.SIGABRT)
                    except OSError:
                        pass
                    dead_processes.append((consumer, name))
                elif self.is_dead(proc, name):
                    dead_processes.append((consumer, name))
                else:
                    active_processes.append(child)

        if dead_processes:
            LOGGER.debug('Removing %i dead process(es)', len(dead_processes))
            for proc in dead_processes:
                self.remove_consumer_process(*proc)
        self._active_cache = time.time(), active_processes
        return active_processes
def active_processes ( self , use_cache = True ) : LOGGER . debug ( 'Checking active processes (cache: %s)' , use_cache ) if self . can_use_process_cache ( use_cache ) : return self . _active_cache [ 1 ] active_processes , dead_processes = list ( ) , list ( ) for consumer in self . consumers : processes = list ( self . consumers [ consumer ] . processes ) for name in processes : child = self . get_consumer_process ( consumer , name ) if child is None : dead_processes . append ( ( consumer , name ) ) elif child . pid is None : dead_processes . append ( ( consumer , name ) ) continue elif child . pid == self . pid : continue try : proc = psutil . Process ( child . pid ) except psutil . NoSuchProcess : dead_processes . append ( ( consumer , name ) ) continue if self . unresponsive [ name ] >= self . MAX_UNRESPONSIVE_COUNT : LOGGER . info ( 'Killing unresponsive consumer %s (%i): ' '%i misses' , name , proc . pid , self . unresponsive [ name ] ) try : os . kill ( child . pid , signal . SIGABRT ) except OSError : pass dead_processes . append ( ( consumer , name ) ) elif self . is_dead ( proc , name ) : dead_processes . append ( ( consumer , name ) ) else : active_processes . append ( child ) if dead_processes : LOGGER . debug ( 'Removing %i dead process(es)' , len ( dead_processes ) ) for proc in dead_processes : self . remove_consumer_process ( * proc ) self . _active_cache = time . time ( ) , active_processes return active_processes
Return a list of all active processes, pruning dead ones

        :rtype: list