how to deal with socket.error: (10060, 'Operation timed out')

JuHui phpbird at gmail.com
Sat Mar 18 13:30:48 CET 2006


I wrote a script to get 100 pages from a server.
like below:

1:import httplib
2:conns = httplib.HTTPConnection("www.mytest.com")
3:conn.request("GET", "/")

sometimes a socket error was raised.

  File "D:\usr\bin\lib\httplib.py", line 627, in connect
    raise socket.error, msg
socket.error: (10060, 'Operation timed out')

how to catch this kind of error then retry the "GET" operation?

btw:
If I want to get many page on same server, which lib is the best
choice? I only know httplib,urllib and urllib2.
thanks a lot.




More information about the Python-list mailing list