我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用multiprocessing.log_to_stderr()。
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)
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
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
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)