Question

I'm looking to get more information about IOError: [Errno socket error] [Errno 10060] when using urlopen in Python 2.7. I am using my personal 35MB/s Internet connection (no proxy).

I've been opening multiple webpages from various websites using a Python script and randomly get this error message from time to time:

webpage = urlopen('http://www.thewebpage.com')


IOError: [Errno socket error] [Errno 10060] A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond

This error appeared after trying to open pages from different websites. Therefore, it doesn't seem to be related exclusively to the opening of pages from one particular website. I also got this error using mechanize.

My questions are :

  1. Is this error related to the fact that I am sending multiple requests to the same server within a short amount of time? Would a time-out reduces the chance of getting this error?
  2. Is there any way to prevent it? Could I use a conditional statement to prevent the script from crashing?

My script takes around an hour to run and having to rerun it due to this error is fairly unpleasant.

Was it helpful?

Solution

Sending multiple requests to the same server in short succession could very well cause the server not to respond, since your requests might look like a ddos attack. You can catch the exception with a try-except clause, and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top