First attempt to handle the nasty socket timeout
Retry once if a http get fails
This commit is contained in:
parent
adeb0241ae
commit
a93dd29c85
1 changed files with 11 additions and 11 deletions
|
@ -43,24 +43,24 @@ class HTTPGetter:
|
||||||
self.httpConnection = HTTPConnection(self.parsedBaseUrl.netloc,80, True)
|
self.httpConnection = HTTPConnection(self.parsedBaseUrl.netloc,80, True)
|
||||||
self.httpRequestHeaders = headers = {'Host':self.parsedBaseUrl.netloc,'Content-Length':0,'Connection':'Keep-Alive','User-Agent':'FlightGear terrasync.py'}
|
self.httpRequestHeaders = headers = {'Host':self.parsedBaseUrl.netloc,'Content-Length':0,'Connection':'Keep-Alive','User-Agent':'FlightGear terrasync.py'}
|
||||||
|
|
||||||
def get(self, httpGetCallback):
|
def doGet(self, httpGetCallback):
|
||||||
|
|
||||||
#self.requests.append(httpGetCallback)
|
|
||||||
conn = self.httpConnection
|
conn = self.httpConnection
|
||||||
request = httpGetCallback
|
request = httpGetCallback
|
||||||
conn.request("GET", self.parsedBaseUrl.path + request.src, None, self.httpRequestHeaders)
|
self.httpConnection.request("GET", self.parsedBaseUrl.path + request.src, None, self.httpRequestHeaders)
|
||||||
|
httpGetCallback.result = self.httpConnection.getresponse()
|
||||||
|
httpGetCallback.callback()
|
||||||
|
|
||||||
|
def get(self, httpGetCallback):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
httpGetCallback.result = conn.getresponse()
|
self.doGet(httpGetCallback)
|
||||||
except:
|
except:
|
||||||
# try to reconnect once
|
# try to reconnect once
|
||||||
#print("reconnect")
|
#print("reconnect")
|
||||||
conn.close()
|
self.httpConnection.close()
|
||||||
conn.connect()
|
self.httpConnection.connect()
|
||||||
conn.request("GET", self.parsedBaseUrl.path + request.src, None, self.httpRequestHeaders)
|
self.doGet(httpGetCallback)
|
||||||
httpGetCallback.result = conn.getresponse()
|
|
||||||
|
|
||||||
httpGetCallback.callback()
|
|
||||||
#self.requests.remove(httpGetCallback)
|
|
||||||
|
|
||||||
#################################################################################################################################
|
#################################################################################################################################
|
||||||
class DirIndex:
|
class DirIndex:
|
||||||
|
|
Loading…
Add table
Reference in a new issue