Skip to content

Instantly share code, notes, and snippets.

@bhatman
Last active August 28, 2015 18:53
Show Gist options
  • Save bhatman/28014b4b6a1c4ea0a83b to your computer and use it in GitHub Desktop.
Save bhatman/28014b4b6a1c4ea0a83b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from multiprocessing.dummy import Pool as ThreadPool
# arbitrary. could base this on the number of cores
PARALLELISM = 5
pool = ThreadPool(PARALLELISM)
def function_to_apply(item):
# do things with item
raise NotImplementedError()
things_to_process = list()
results = pool.map(function_to_apply, things_to_process)
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment