Minimal Example for Python Multiprocessing

The following is a minimal example for multiprocessing in Python. A very useful guide written by Jan Bodnar is here.

from multiprocessing import Process

def fun(i):
    return i

def main():
    proc = []

    for i in 1:100:
        p = Process(target=fun, args=(i, ))
        p.start()
        proc.append(p)

    for p in proc:
        p.join()

if __name__ == '__main__':
    main()

You'll only receive email when they publish something new.

More from Spark Tseung
All posts