mamaduckmaster / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Better handling of stale keep-alive connections. #250

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
So, httplib2 keeps connections around and reuses them, and under HTTP
1.1 keep-alive is the default behavior, so this should result in 
making multiple requests to the same server much faster.

But keep alive only lasts for so long, eventually if the connection is
idle long enough the server will close the connection. If httplib2 tries 
to use that connection after the server has closed connection then you 
get a BadStatusLine exception, because the read from that socket returns 
the empty string.

Now one of the complaints about httplib2 was that
it defaulted to 2 retries on every request, so if you set your
connection timeout to 30s and a request really did timeout, it would 
actually try the request twice and not return until 60s later. 
So, httplib2.RETRIES was added, but if you set it to 1 then the 
BadStatusLine exceptions that get raised by stale connections
don't get retried.

Add a special case to the retry logic in httplib2 for BadStatusLine exceptions,
regardless of the httplib2.RETRIES value.

Original issue reported on code.google.com by joe.gregorio@gmail.com on 8 Mar 2013 at 3:22

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 4adde1593f41.

Original comment by joe.gregorio@gmail.com on 8 Mar 2013 at 7:15