my multi-download program can't finish
守株待兔
1248283536 at qq.com
Thu Sep 8 00:24:15 EDT 2011
here is the program,
# basic structure,omit something
import Queue
import httplib2
import threading
jobs = Queue.Queue()
name=something #omit ,it is a web list to download
for x in name:
jobs.put(x)
def download():
while not jobs.empty():
try:
url = jobs.get()
hx = httplib2.Http()
resp, content = hx.request(url, headers=headers)
jobs.task_done()
except:
print "wrong" , url
if __name__ == '__main__':
for i in range(10):
threading.Thread(target=download).start()
jobs.join()
when it run ,it can download someting ,
it is strang:there is wrong output ,some web can't get,but the program can't stop,it stay ,run ,can't fininsh,
i don't know why?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110908/57cad059/attachment.html>
More information about the Python-list
mailing list