7

I am doing a big loop of http requests to our database service. It all works fine, but whenever I run it, after a (seemingly random) number of successful queries, I receive the following error : urllib2.URLError: <urlopen error [Errno 1] _ssl.c:504: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure>.

I am using python, urllib2 to send the request, urllib to encode some stuff in my URL, and that's it. Like I said, it looks totally random. I just ran it and it failed after 6 requests. The time before, it crashed after 49 successfull tries. Has anyone had this issue before?

Thanks

Eric Smith
  • 2,739
  • 2
  • 30
  • 29

3 Answers3

0

It is more concerned to the Network but not your code.

I suggest that you could use the requests module with retry inside the module.

Or you could add some retry in your code.

For example, you could write like this:

for i in range(reties):
    try:
       resp = xx.get(url)
       result = resp.get_result
    except (ConnectionError, SocketError or whatever else):
       pass
else:
    arise Exception('Retry Error')
Zagfai
  • 418
  • 2
  • 12
-1

Seriously, you should try Python Requests instead of urllib2 if you are not restricted to core packages.

Stan
  • 8,710
  • 2
  • 29
  • 31
-1

Stan I think that Scrapy is more faster and can deal with all type of connection error.

Eric I suggest you to check scrapy you will be amazed by it's speed and features

Shlomy

Shalom Balulu
  • 379
  • 1
  • 9
  • 20