Created
November 16, 2016 02:23
-
-
Save jovianlin/1ad5544f3c8c3283124a7112667e9d74 to your computer and use it in GitHub Desktop.
Test Multiprocessing Pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
def job(x): | |
return x ** 2 | |
# End of job(...). | |
if __name__ == "__main__": | |
p = Pool(processes=50) | |
data_1 = p.map(job, range(10)) | |
data_2 = p.map(job, [99, 111, 7236]) | |
p.close() | |
print "data_1: {}".format(data_1) | |
print "data_2: {}".format(data_2) | |
# End of __main__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment