A version of multiprocessing.Pool.map that works using dill to pickle the
    function and iterable

def distribute(function, iterable, *, workers=4):
    """
    A version of multiprocessing.Pool.map that works using dill to pickle the
    function and iterable
    """
    with multiprocessing.Pool(workers) as pool:
        processes = []
        for item in iterable:
            pickled = dill.dumps((function, item))
            process = pool.apply_async(_run_pickled, (pickled,))
            processes.append(process)

        results = [process.get() for process in processes]
    return results