def __init__(self): try: cpus = cpu_count() except NotImplementedError: cpus = 1 self._taskqueue = Queue(maxsize=(2 * cpus)) Pool.__init__(self)
def __init__(self, processes=None, initializer=None, initargs=(), process=None): """ @param process: Process subclass to use """ if process is not None: self.Process = process Pool.__init__(self, processes, initializer, initargs)
def __init__(self, processes=None, initializer=None, initargs=(), maxtasksperchild=None): if max_top_workers: processes = int(max_top_workers) Pool.__init__(self, processes, initializer, initargs, maxtasksperchild)
def __init__(self, ncpu, initializer=None, initargs=(), maxtasksperchild=None, limit=True): """ INPUTS ------ ncpu: int (default 0, i.e, built-in map behavior) number of cpu to use for the mapping. 0 is equivalent to calling the built-in map function <0 is equivalent to requesting all cpus initializer: callable if set, each worker process will call initializer(*initargs) when it starts. initargs: tuple arguments to use with the initializer maxtasksperchild: int number of tasks a worker process can complete before it will exit and be replaced with a fresh worker process, to enable unused resources to be freed. The default maxtasksperchild is None, which means worker processes will live as long as the pool. limit: bool (default True) if ncpu is greater than the number of available cpus, setting this keyword will limit the request to the maximum available Note: sometimes the os load controller does awesome and some speed-up could be obtained when requesting more cpus than available """ _n = _mp.cpu_count() if (ncpu <= 0): # use all available cpus self._n = _n elif (ncpu > _n) & (limit is True): self._n = _n else: self._n = ncpu new_initializer = Partial(_initializer_wrapper, initializer) _Pool.__init__(self, processes=self._n, initializer=new_initializer, initargs=initargs, maxtasksperchild=maxtasksperchild)
def __init__(self, *args, **kwargs): handler = None if logging.getLogger().handlers: # Use an existing lo handler if already setup. handler = logging.getLogger().handlers[0] else: # Otherwise use some good defaults. handler = logging.StreamHandler(sys.stderr) handler.setLevel(logging.INFO) handler.setFormat( logging.Formatter( '%(created)f %(filename)s:%(lineno)s [%(funcName)s] %(message)s')) multiprocessing.get_logger().addHandler(handler) kwargs['initializer'] = lambda: signal.signal(signal.SIGINT, signal.SIG_IGN) NativePool.__init__(self, *args, **kwargs) self.results = [] self.prev_message = None
def __init__(self, *args, **kwargs): handler = None if logging.getLogger().handlers: # Use an existing lo handler if already setup. handler = logging.getLogger().handlers[0] else: # Otherwise use some good defaults. handler = logging.StreamHandler(sys.stderr) handler.setLevel(logging.INFO) handler.setFormat( logging.Formatter( '%(created)f %(filename)s:%(lineno)s [%(funcName)s] %(message)s' )) multiprocessing.get_logger().addHandler(handler) kwargs['initializer'] = lambda: signal.signal(signal.SIGINT, signal. SIG_IGN) NativePool.__init__(self, *args, **kwargs) self.results = [] self.prev_message = None
def __init__(self, *args, **kwds): Pool.__init__(self, *args, **kwds) self.results = [] self.int_results = []
def __init__(self, *args, **kwargs): self.Process = CAProcess Pool.__init__(self, *args, **kwargs)
def __init__(self, processes): Pool.__init__(self, processes, ignoreSigInt)
def __init__(self, process_num): Pool.__init__(self, process_num) self.process_num = process_num
def __init__( self, processes ): Pool.__init__( self, processes, ignoreSigInt )
def __init__(self, processes=None): """ MyPoolwithPipe的构造函数 :param processes: 最大进程数 """ BasePool.__init__(self, processes)
def __init__(self, processes=None, initializer=None, initargs=()): Pool.__init__(self, processes, initializer, initargs) self._taskqueue.maxsize = self._processes self._inqueue.maxsize = self._processes self._outqueue.maxsize = self._processes
def __init__(self, processes=None, initializer=None, initargs=()): if max_top_workers: processes = int(max_top_workers) Pool.__init__(self, processes, initializer, initargs)