Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import urllib2
- from multiprocessing.dummy import Pool as ThreadPool
- urls = [
- 'https://medium.com/p/40e9b2b36148'
- # Thanks for the awesome tut in parallelism
- # follow the link above for full tut
- ]
- # Make the Pool of workers
- pool = ThreadPool(4)
- # Open the urls in their own threads
- # and return the results
- results = pool.map(urllib2.urlopen, urls)
- # Close the pool and wait for the work to finish
- pool.close()
- pool.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement