Last active
June 17, 2019 15:20
-
-
Save bhpayne/aef62abe1c82acef536b4ae62be9885b to your computer and use it in GitHub Desktop.
This file contains 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
import multiprocessing | |
def serial_func(arg1): | |
return arg1*2 | |
if __name__ == '__main__': | |
start_time=time.time() | |
res_list=[] | |
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool: # start worker processes | |
res_list = pool.map(serial_func,[3,4,5]) # see https://docs.python.org/3/library/multiprocessing.html | |
print('main elapsed:',time.time()-start_time,'seconds') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment