X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cef69b16e1295e456548813ad95c9db827136c17..32e3f6eb604d3692f10f16220a78e07c056be00e:/sdk/python/arvados/safeapi.py diff --git a/sdk/python/arvados/safeapi.py b/sdk/python/arvados/safeapi.py index 539f1e62cc..5c5c87250a 100644 --- a/sdk/python/arvados/safeapi.py +++ b/sdk/python/arvados/safeapi.py @@ -4,10 +4,12 @@ import keep import config import copy -class SafeApi(object): - """Threadsafe wrapper for API object. This stores and returns a different api - object per thread, because httplib2 which underlies apiclient is not - threadsafe. +class ThreadSafeApiCache(object): + """Threadsafe wrapper for API objects. + + This stores and returns a different api object per thread, because httplib2 + which underlies apiclient is not threadsafe. + """ def __init__(self, apiconfig=None, keep_params={}): @@ -19,14 +21,11 @@ class SafeApi(object): def localapi(self): if 'api' not in self.local.__dict__: - self.local.api = api.api('v1', False, apiconfig=self.apiconfig) + self.local.api = api.api_from_config('v1', apiconfig=self.apiconfig) return self.local.api def __getattr__(self, name): # Proxy nonexistent attributes to the thread-local API client. if name == "api_token": return self.apiconfig['ARVADOS_API_TOKEN'] - try: - return getattr(self.localapi(), name) - except AttributeError: - return super(SafeApi, self).__getattr__(name) + return getattr(self.localapi(), name)