Set timeout in http connections

parent c7def2c1
......@@ -25,6 +25,8 @@ import traceback
import urllib2
import urlparse
# Upload/download timeout is one day
TIMEOUT = 3600 * 24
class NetworkcacheClient(object):
'''
......@@ -134,10 +136,10 @@ class NetworkcacheClient(object):
if self.shacache_scheme == 'https':
shacache_connection = httplib.HTTPSConnection(self.shacache_host,
self.shacache_port, key_file=self.shacache_key_file,
cert_file=self.shacache_cert_file)
cert_file=self.shacache_cert_file, timeout=TIMEOUT)
else:
shacache_connection = httplib.HTTPConnection(self.shacache_host,
self.shacache_port)
self.shacache_port, timeout=TIMEOUT)
try:
shacache_connection.request('POST', self.shacache_path, file_descriptor,
self.shacache_header_dict)
......@@ -176,10 +178,10 @@ class NetworkcacheClient(object):
if self.shadir_scheme == 'https':
shadir_connection = httplib.HTTPSConnection(self.shadir_host,
self.shadir_port, key_file=self.shadir_key_file,
cert_file=self.shadir_cert_file)
cert_file=self.shadir_cert_file, timeout=TIMEOUT)
else:
shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port)
self.shadir_port, timeout=TIMEOUT)
try:
shadir_connection.request('PUT', '/'.join([self.shadir_path, key]),
json.dumps(data), self.shadir_header_dict)
......@@ -211,10 +213,10 @@ class NetworkcacheClient(object):
if self.shacache_scheme == 'https':
shacache_connection = httplib.HTTPSConnection(self.shacache_host,
self.shacache_port, key_file = self.shacache_key_file,
cert_file = self.shacache_cert_file)
cert_file = self.shacache_cert_file, timeout=TIMEOUT)
else:
shacache_connection = httplib.HTTPConnection(self.shacache_host,
self.shacache_port)
self.shacache_port, timeout=TIMEOUT)
try:
shacache_connection.request('POST', self.shacache_path, file_descriptor,
self.shacache_header_dict)
......@@ -239,10 +241,10 @@ class NetworkcacheClient(object):
if self.shadir_scheme == 'https':
shadir_connection = httplib.HTTPSConnection(self.shadir_host,
self.shadir_port, key_file = self.shadir_key_file,
cert_file = self.shadir_cert_file)
cert_file = self.shadir_cert_file, timeout=TIMEOUT)
else:
shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port)
self.shadir_port, timeout=TIMEOUT)
try:
shadir_connection.request('PUT', '/'.join([self.shadir_path, key]),
json.dumps(data), self.shadir_header_dict)
......
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