I've tried to get a very simple multiprocessing script to work and am failing to figure out what I'm doing wrong. I'm utilizing Python 2.7.5 64bit on win32. I was looking at Python Multiprocessing help exit on condition for assistance.
Style 1:
import multiprocessing
def doCalc(year):
return year*year
yearlist = [1,2,3,4]
print(yearlist)
pool = multiprocessing.Pool(4)
for i in yearlist:
pool.apply_async(doCalc, args=[i])
pool.close()
pool.join()
Style 2:
import multiprocessing
def doCalc(year):
return year*year
yearlist = [1,2,3,4]
print(yearlist)
pool = multiprocessing.Pool(4)
pool.map(doCalc, yearlist)
Both scripts print [1,2,3,4] and then do nothing. Thanks for any help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.