my multi-download program can't finish

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Sep 8 07:08:38 CEST 2011


On Thu, 8 Sep 2011 02:24 pm 守株待兔 wrote:

[...]
>              try:
>                  url = jobs.get()
>                  hx = httplib2.Http()
>                  resp, content = hx.request(url, headers=headers)
>                  jobs.task_done()
>              except:
>                  print  "wrong" , url

> 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?

If you read the helpful error messages that Python provides, instead of
hiding them and printing a useless message "wrong", you might find out why
the failures are happening.

Get rid of the try...except and see what exceptions you get. Then you will
be in a better situation to decide which exceptions should be caught, and
which are bugs that need to be fixed, and which should be allowed through.



-- 
Steven




More information about the Python-list mailing list