Python multiprocessing 模块,log_to_stderr() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用multiprocessing.log_to_stderr()

项目:Piwho    作者:Adirockzz95    | 项目源码 | 文件源码
def start_service(self):
        """
        start speaker training service.
        """
        # prevent signal from propagating to child process
        handler = signal.getsignal(signal.SIGINT)
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        if self.debug:
            self.sprecog.debug = True
            mp.log_to_stderr(logging.DEBUG)

        self.sprecog.speaker_name = self.speaker_name
        self.proc = mp.Process(name="watchdog", target=self.__run,
                               args=(self.event,))
        self.proc.setDaemon = False
        self.proc.start()
        # restore signal
        signal.signal(signal.SIGINT, handler)
项目:BrundleFuzz    作者:carlosgprado    | 项目源码 | 文件源码
def main():
    """Starts several processes

    This must be kept to the bare minimum
    """
    multiprocessing.log_to_stderr()
    logger = multiprocessing.get_logger()
    logger.setLevel(logging.INFO)

    jobs = []

    try:
        bfs = BrundleFuzzServer()
        jobs.append(bfs)
        bfs.start()

        for j in jobs:
            j.join()

    except KeyboardInterrupt:
        pass
项目:pypers    作者:frankosan    | 项目源码 | 文件源码
def __init__(self):
        """
        Initialize the manager
        """
        self.logger = mp.log_to_stderr()
        self.logger.handlers[0].setFormatter(PipeFormatter())

        self.submitted = []
        self.actions = []
        self.process_thread = Thread(target=self.process)
        self.lock = Lock()
        self.pool = {'steps': '', 'pipelines': ''}

        self.pool['pipelines'] = mp.Pool(processes=MAX_PIPELINES,
                                         initializer=init_worker,
                                         maxtasksperchild=1)

        self.pool['steps'] = mp.Pool(processes=MAX_STEPS,
                                     initializer=init_worker,
                                     maxtasksperchild=1)

        self.manager = mp.Manager()
        self.pids = self.manager.dict()
        self.count = 0
项目:kafka-splunk-consumer    作者:sghaskell    | 项目源码 | 文件源码
def initLogger(self):
        """ Initialize logger and set to loglevel"""
        loglevel = self.loglevels[self.loglevel]
        log_format = '%(asctime)s name=%(name)s loglevel=%(levelname)s message=%(message)s'
        logging.basicConfig(format=log_format,
                            level=loglevel)
        multiprocessing.log_to_stderr(loglevel)