Add correct timeout settings.

parent 35c0b582
......@@ -28,8 +28,10 @@ import urlparse
# XXX: code between select/select_generic and upload/upload_generic should be
# factored
# Upload/download timeout is one day
TIMEOUT = 3600 * 24
# Timeout here is about timeout to CONNECT to the server (socket initialization then server answers actual data), not to retrieve/send informations.
# To be clear: it is NOT about uploading/downloading data, but about time to connect to the server, then time that server takes to start answering.
TIMEOUT = 3600
class NetworkcacheClient(object):
'''
......@@ -275,7 +277,7 @@ class NetworkcacheClient(object):
sha_cache_url = os.path.join(self.shacache_url, sha512sum)
request = urllib2.Request(url=sha_cache_url, data=None,
headers=self.shadir_header_dict)
return urllib2.urlopen(request)
return urllib2.urlopen(request, timeout=TIMEOUT)
def select(self, key):
''' Download a file from shacache by selecting the entry in shadir
......@@ -284,7 +286,7 @@ class NetworkcacheClient(object):
url = os.path.join(self.shadir_url, key)
request = urllib2.Request(url=url, data=None,
headers=self.shadir_header_dict)
data = urllib2.urlopen(request).read()
data = urllib2.urlopen(request, timeout=TIMEOUT).read()
# Filtering...
try:
data_list = json.loads(data)
......@@ -323,7 +325,7 @@ class NetworkcacheClient(object):
url = os.path.join(self.shadir_url, key)
request = urllib2.Request(url=url, data=None,
headers=self.shadir_header_dict)
data = urllib2.urlopen(request).read()
data = urllib2.urlopen(request, timeout=TIMEOUT).read()
try:
data_list = json.loads(data)
except Exception:
......@@ -417,3 +419,4 @@ class DirectoryNotFound(Exception):
class UploadError(Exception):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment