Skip to content

Instantly share code, notes, and snippets.

@boxrick
Created May 11, 2018 10:39
Show Gist options
  • Save boxrick/440cad3ff9cccc813abd3cf571d458c5 to your computer and use it in GitHub Desktop.
Save boxrick/440cad3ff9cccc813abd3cf571d458c5 to your computer and use it in GitHub Desktop.
Threaded example
import multiprocessing
from multiprocessing import Pool
from time import sleep
list_of_numbers = list(xrange(101))
def pull_role(stuff):
print('Sleeping ' + str(stuff))
sleep(0.1)
if __name__ == "__main__":
core_count = multiprocessing.cpu_count()*2
print ('calculated cores: ' + str(core_count))
p = Pool(processes=core_count)
result = p.map(pull_role, list_of_numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment