Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
python / multiprocessing test in case a function has multi arguments.
from multiprocessing import Pool
import os
import time
start = time.time()
def func(n, a1, a2):
r = n * a1 + a2
print('time:{:1.16f} r:{:5d} pid:{}'.format(time.time() - start, r, os.getpid()))
return r
def wrapper(args):
return func(*args)
if __name__ == '__main__':
process = 3
lst = [(i, 2, 5) for i in range(10)]
p = Pool(process)
output =, lst)
print(time.time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment