mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
we need to retry when we get BadStatusLine
this is caused by the http keep alive being closed by the server
This commit is contained in:
parent
d506515564
commit
6ed971cb6b
1 changed files with 46 additions and 39 deletions
|
@ -448,7 +448,9 @@ httplib.HTTPConnection.send = _incrementalSend
|
|||
# this is an augmented version of httplib's request routine that:
|
||||
# - doesn't assume requests will be tried more than once
|
||||
# - calls a hook for each chunk of data so we can update the gui
|
||||
# - retries only when keep-alive connection is closed
|
||||
def _conn_request(self, conn, request_uri, method, body, headers):
|
||||
for i in range(2):
|
||||
try:
|
||||
if conn.sock is None:
|
||||
conn.connect()
|
||||
|
@ -470,6 +472,11 @@ def _conn_request(self, conn, request_uri, method, body, headers):
|
|||
raise
|
||||
try:
|
||||
response = conn.getresponse()
|
||||
except httplib.BadStatusLine:
|
||||
print "retry bad line"
|
||||
conn.close()
|
||||
conn.connect()
|
||||
continue
|
||||
except (socket.error, httplib.HTTPException):
|
||||
raise
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue