import timer
import datetime
import ssl
+import socket
_logger = logging.getLogger('arvados.keep')
global_client_object = None
class KeepService(object):
# Make requests to a single Keep service, and track results.
HTTP_ERRORS = (httplib2.HttpLib2Error, httplib.HTTPException,
- ssl.SSLError)
+ socket.error, ssl.SSLError)
def __init__(self, root, **headers):
self.root = root
self.service.last_result[1])
- def __init__(self, api_client=None, proxy=None, timeout=60,
+ def __init__(self, api_client=None, proxy=None, timeout=300,
api_token=None, local_store=None):
"""Initialize a new KeepClient.
of the ARVADOS_KEEP_PROXY configuration setting. If you want to
ensure KeepClient does not use a proxy, pass in an empty string.
* timeout: The timeout for all HTTP requests, in seconds. Default
- 60.
+ 300.
* api_token: If you're not using an API client, but only talking
directly to a Keep proxy, this parameter specifies an API token
to authenticate Keep requests. It is an error to specify both
import mock
import os
+import socket
import unittest
import arvados
with self.mock_responses(self.DEFAULT_EXPECT, 404, 200, 500):
self.check_success(locator=self.HINTED_LOCATOR)
+ def test_try_next_server_after_timeout(self):
+ responses = iter([None, (fake_httplib2_response(200),
+ self.DEFAULT_EXPECT)])
+ def side_effect(*args, **kwargs):
+ response = next(responses)
+ if response is None:
+ raise socket.timeout("timed out")
+ else:
+ return response
+ with mock.patch('httplib2.Http.request', side_effect=side_effect):
+ self.check_success(locator=self.HINTED_LOCATOR)
+
@no_backoff
class KeepClientRetryPutTestCase(unittest.TestCase, KeepClientRetryTestMixin):