Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
multiprocess pool test
import multiprocessing as mp
def job(x):
return x * x
pool = mp.Pool()
res = pool.map(job, range(10))
def multicore():
pool = mp.Pool()
res = pool.map(job, range(10))
print(res)
def multicore():
pool = mp.Pool(processes=3) # 定义CPU核数量为3
res = pool.map(job, range(10))
print(res)
if __name__ == '__main__':
multicore()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.