Пример #1
0
def test():
    print("Creating 5 (non-daemon) workers and jobs in main process.")
    pool = MyPool(5)

    result = pool.map(work1, np.arange(5)+1)

    pool.close()
    pool.join()
    print(result)
Пример #2
0
def work1(num_procs):
    print("WORK1: Creating %i (daemon) workers and jobs in child." % num_procs)
    # pool = multiprocessing.Pool(num_procs)
    pool = MyPool(num_procs)

    result = pool.map(work2,
                      np.repeat(num_procs, num_procs))

    # The following is not really needed, since the (daemon) workers of the
    # child's pool are killed when the child is terminated, but it's good
    # practice to cleanup after ourselves anyway.
    pool.close()
    pool.join()
    return result