how to deal with socket.error: (10060, 'Operation timed out')
fredrik at pythonware.com
Sat Mar 18 13:41:19 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')
(given the code you quoted, a NameError would be more likely...)
> how to catch this kind of error then retry the "GET" operation?
the same way as you'd catch any other kind of error in Python:
if you want to repeat an operation until it succeeds, use a loop:
break # success
for details, see
More information about the Python-list