Skip to content

Instantly share code, notes, and snippets.

@adamghill
Created January 27, 2014 15:39
Show Gist options
  • Save adamghill/8650711 to your computer and use it in GitHub Desktop.
Save adamghill/8650711 to your computer and use it in GitHub Desktop.
Simple multi-threading in Python. Cribbed from: https://medium.com/building-things-on-the-internet/40e9b2b36148.
import urllib2
from multiprocessing.dummy import Pool as ThreadPool
urls = [
'http://www.python.org',
'http://www.python.org/about/',
]
pool = ThreadPool()
results = pool.map(urllib2.urlopen, urls)
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment