Created
January 18, 2014 07:58
-
-
Save gr33ndata/8487613 to your computer and use it in GitHub Desktop.
Python Multiprocessing using Pool.map
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 time import sleep | |
| from multiprocessing import Pool | |
| def fun(i): | |
| if i % 2: | |
| sleep(2) | |
| print i | |
| pool = Pool(4) | |
| pool.map(fun,range(40)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment