Skip to content

Instantly share code, notes, and snippets.

@bhpayne
Last active June 17, 2019 15:20
Show Gist options
  • Save bhpayne/aef62abe1c82acef536b4ae62be9885b to your computer and use it in GitHub Desktop.
Save bhpayne/aef62abe1c82acef536b4ae62be9885b to your computer and use it in GitHub Desktop.
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