Search code examples
pythonpython-3.xpython-multiprocessingpathos

equivalent functionality to multiprocessing.Pool's join in pathos


I'm using multiprocessing.Process to prevent some function from running for too long.

I'd like to use pathos instead of python's multiprocessing (due to it's ability to handle things that the standard multiprocessing package can't), but it seems like some functionality is lacking: I can't find anything in pathos which allows for join with a timeout argument.

I'm hoping there is something of the sort which will allow me to terminate a process once some time has passed.

(I'm using windows, so the simplest alternative - using signal - is not possible, and the alternatives seem extremely complicated)


Solution

  • I'm the pathos author. You might want to try multiprocess, which is a fork of multiprocessing (and is what is underneath pathos). You should already have it installed if you have pathos installed.

    You can get to Process either of these two ways, where it has all of the same functionality as in multiprocessing (plus the additional serialization capabilities from dill):

    >>> import pathos
    >>> pathos.helpers.mp.Process
    <class 'multiprocess.process.Process'>
    >>> import multiprocess
    >>> multiprocess.Process
    <class 'multiprocess.process.Process'>
    

    So, any object found in multiprocessing with a timeout argument can also be found as above.