View difference between Paste ID: Z5MdeB5x and npVs83vG
SHOW: | | - or go back to the newest paste.
1
import threading
2
import urllib2
3
import time
4
5
start = time.time()
6
urls = ["http://www.google.com", "http://www.apple.com", "http://www.microsoft.com", "http://www.amazon.com", "http://www.facebook.com"]
7
8
def fetch_url(url):
9-
    urlHandler = urllib2.urlopen(self.url)
9+
    urlHandler = urllib2.urlopen(url)
10
    html = urlHandler.read()
11-
    print "'%s\' fetched in %ss" % (self.url,(time.time() - start))
11+
    print "'%s\' fetched in %ss" % (url, (time.time() - start))
12
13
threads = [threading.Thread(target=fetch_url, args=(url,)) for url in urls]
14
for thread in threads:
15
    thread.start()
16
for thread in threads:
17
    thread.join()
18
19
print "Elapsed Time: %s" % (time.time() - start)

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×