Skip to content

suggest pathos support initializer parameter for pathos.multiprocessing.ProcessPool #220

@liningbo

Description

@liningbo

Sometimes We need to do some Initialization work when start new process, but pathos.multiprocessing.ProcessPool seem not support it. The multiprocessing.Pool has the initializer parameter, so suggest pathos support initializer parameter for pathos.multiprocessing.ProcessPool as multiprocessing.Pool. Thank you.

class Pool(object):
'''
Class which supports an async version of applying functions to arguments.
'''
_wrap_exception = True

@staticmethod
def Process(ctx, *args, **kwds):
    return ctx.Process(*args, **kwds)

def __init__(self, processes=None, initializer=None, initargs=(),
             maxtasksperchild=None, context=None):
    # Attributes initialized early to make sure that they exist in
    # __del__() if __init__() raises an exception
    self._pool = []
    self._state = INIT

    self._ctx = context or get_context()
    self._setup_queues()
    self._taskqueue = queue.SimpleQueue()
    # The _change_notifier queue exist to wake up self._handle_workers()
    # when the cache (self._cache) is empty or when there is a change in
    # the _state variable of the thread that runs _handle_workers.
    self._change_notifier = self._ctx.SimpleQueue()
    self._cache = _PoolCache(notifier=self._change_notifier)
    self._maxtasksperchild = maxtasksperchild
    self._initializer = initializer
    self._initargs = initargs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions