Hey guys...
I have some code here:
import os
import threading
import urllib
import time
a=0
class launch(threading.Thread):
def start_now():
try:
urllib.urlopen("http://www.google.com")
except:
a+=1
start_now()
def end():
print("\nOut of 10000 requests, "+str(a)+" requests failed.")
for x in range(10001):
launch().start()
print("http://www.google.com")
end()
raw_input("<Done>")
This works, in the sense that it goes on and on printing "www.google.com", but the same code a little modified doesn't work:
import os
import threading
import urllib
import time
a=0
class launch(threading.Thread):
def start_now():
try:
print("http://www.google.com")
urllib.urlopen("http://www.google.com")
except:
a+=1
start_now()
def end():
print("\nOut of 10000 requests, "+str(a)+" requests failed.")
for x in range(10001):
launch().start()
end()
raw_input("<Done>")
It only prints "http://www.google.com" once and nothing happens! What's the difference in code I posted?
Thanks guys!