[ARVADOS] updated: 4ef537243058616754efde56438a193626556bca
git at public.curoverse.com
git at public.curoverse.com
Wed Sep 10 14:24:51 EDT 2014
Summary of changes:
sdk/python/arvados/keep.py | 7 ++++---
sdk/python/tests/test_keep_client.py | 13 +++++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
via 4ef537243058616754efde56438a193626556bca (commit)
from bafb417c531d6094697a13a7465313d1cc7c0bc9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 4ef537243058616754efde56438a193626556bca
Author: Brett Smith <brett at curoverse.com>
Date: Wed Sep 10 14:22:01 2014 -0400
3846: Improve timeout handling in PySDK KeepClient.
* Catch socket errors (including timeouts) and treat them as
transient with regard to retry logic.
* Increase the default timeout to 5 minutes. Given how long it can
take to PUT 64MiB to a proxy and wait for two servers to return
success, this seems like a reasonable default. Future improvements
could set different timeouts based on the request type and whether
or not we're talking to a proxy.
Closes #3846.
diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index 651cec4..f0a8724 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -20,6 +20,7 @@ import threading
import timer
import datetime
import ssl
+import socket
_logger = logging.getLogger('arvados.keep')
global_client_object = None
@@ -204,7 +205,7 @@ class KeepClient(object):
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
@@ -324,7 +325,7 @@ class KeepClient(object):
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.
@@ -337,7 +338,7 @@ class KeepClient(object):
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
diff --git a/sdk/python/tests/test_keep_client.py b/sdk/python/tests/test_keep_client.py
index 4ac9df1..04bcab8 100644
--- a/sdk/python/tests/test_keep_client.py
+++ b/sdk/python/tests/test_keep_client.py
@@ -1,5 +1,6 @@
import mock
import os
+import socket
import unittest
import arvados
@@ -310,6 +311,18 @@ class KeepClientRetryGetTestCase(unittest.TestCase, KeepClientRetryTestMixin):
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):
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list